Fix simple tests

This commit is contained in:
Ben Charlton 2020-08-21 18:53:51 +01:00
parent f7ed48809c
commit c31b30bf83
3 changed files with 7 additions and 8 deletions

View File

@ -220,5 +220,5 @@ class BuildTest(TestCase):
# And a new stock item created for the build output
self.assertEqual(StockItem.objects.get(pk=7).quantity, 1)
self.assertEqual(StockItem.objects.get(pk=7).serial, 1)
self.assertEqual(StockItem.objects.get(pk=7).serial, "1")
self.assertEqual(StockItem.objects.get(pk=7).build, self.build)

View File

@ -346,11 +346,13 @@ class Part(MPTTModel):
if n is None:
return 1
elif n is int:
return n + 1
else:
try:
return int(n) + 1
except ValueError:
return None
def getSerialNumberString(self, quantity):
"""
Return a formatted string representing the next available serial numbers,

View File

@ -295,10 +295,7 @@ class StockTest(TestCase):
with self.assertRaises(ValidationError):
item.serializeStock(-1, [], self.user)
# Try invalid serial numbers
with self.assertRaises(ValidationError):
item.serializeStock(3, [1, 2, 'k'], self.user)
# Not enough serial numbers for all stock items.
with self.assertRaises(ValidationError):
item.serializeStock(3, "hello", self.user)