mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
always return a number
This commit is contained in:
parent
624b16a419
commit
972f93f6d8
@ -504,7 +504,7 @@ def extract_serial_numbers(serials, expected_quantity, next_number: int):
|
|||||||
if group in numbers:
|
if group in numbers:
|
||||||
errors.append(_("Duplicate serial: {g}".format(g=group)))
|
errors.append(_("Duplicate serial: {g}".format(g=group)))
|
||||||
else:
|
else:
|
||||||
numbers.append(group)
|
numbers.append(int(group))
|
||||||
|
|
||||||
if len(errors) > 0:
|
if len(errors) > 0:
|
||||||
raise ValidationError(errors)
|
raise ValidationError(errors)
|
||||||
|
@ -255,15 +255,15 @@ class TestSerialNumberExtraction(TestCase):
|
|||||||
|
|
||||||
sn = e("4, 1+2", 4, 1)
|
sn = e("4, 1+2", 4, 1)
|
||||||
self.assertEqual(len(sn), 4)
|
self.assertEqual(len(sn), 4)
|
||||||
self.assertEqual(sn, ["4", 1, 2, 3])
|
self.assertEqual(sn, [4, 1, 2, 3])
|
||||||
|
|
||||||
sn = e("~", 1, 1)
|
sn = e("~", 1, 1)
|
||||||
self.assertEqual(len(sn), 1)
|
self.assertEqual(len(sn), 1)
|
||||||
self.assertEqual(sn, ['1'])
|
self.assertEqual(sn, [1])
|
||||||
|
|
||||||
sn = e("~", 1, 3)
|
sn = e("~", 1, 3)
|
||||||
self.assertEqual(len(sn), 1)
|
self.assertEqual(len(sn), 1)
|
||||||
self.assertEqual(sn, ['3'])
|
self.assertEqual(sn, [3])
|
||||||
|
|
||||||
sn = e("~+", 2, 5)
|
sn = e("~+", 2, 5)
|
||||||
self.assertEqual(len(sn), 2)
|
self.assertEqual(len(sn), 2)
|
||||||
@ -305,11 +305,11 @@ class TestSerialNumberExtraction(TestCase):
|
|||||||
|
|
||||||
sn = e("1 3-5 9+2", 7, 1)
|
sn = e("1 3-5 9+2", 7, 1)
|
||||||
self.assertEqual(len(sn), 7)
|
self.assertEqual(len(sn), 7)
|
||||||
self.assertEqual(sn, ['1', 3, 4, 5, 9, 10, 11])
|
self.assertEqual(sn, [1, 3, 4, 5, 9, 10, 11])
|
||||||
|
|
||||||
sn = e("1,3-5,9+2", 7, 1)
|
sn = e("1,3-5,9+2", 7, 1)
|
||||||
self.assertEqual(len(sn), 7)
|
self.assertEqual(len(sn), 7)
|
||||||
self.assertEqual(sn, ['1', 3, 4, 5, 9, 10, 11])
|
self.assertEqual(sn, [1, 3, 4, 5, 9, 10, 11])
|
||||||
|
|
||||||
sn = e("~+2", 3, 14)
|
sn = e("~+2", 3, 14)
|
||||||
self.assertEqual(len(sn), 3)
|
self.assertEqual(len(sn), 3)
|
||||||
|
Loading…
Reference in New Issue
Block a user