mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fixes for unit tests
This commit is contained in:
parent
9475af62ae
commit
6d2cd78d29
@ -382,7 +382,7 @@ class Part(MPTTModel):
|
|||||||
logger.info(f"Deleting unused image file '{previous.image}'")
|
logger.info(f"Deleting unused image file '{previous.image}'")
|
||||||
previous.image.delete(save=False)
|
previous.image.delete(save=False)
|
||||||
|
|
||||||
self.clean()
|
self.full_clean()
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
@ -332,21 +332,24 @@ class PartSettingsTest(TestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Create a part
|
# Create a part
|
||||||
Part.objects.create(name='Hello', description='A thing', IPN='IPN123')
|
Part.objects.create(name='Hello', description='A thing', IPN='IPN123', revision='A')
|
||||||
|
|
||||||
# Attempt to create a duplicate item (should fail)
|
# Attempt to create a duplicate item (should fail)
|
||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
Part.objects.create(name='Hello', description='A thing', IPN='IPN123')
|
part = Part(name='Hello', description='A thing', IPN='IPN123', revision='A')
|
||||||
|
part.validate_unique()
|
||||||
|
|
||||||
# Attempt to create item with duplicate IPN (should be allowed by default)
|
# Attempt to create item with duplicate IPN (should be allowed by default)
|
||||||
Part.objects.create(name='Hello', description='A thing', IPN='IPN123', revision='B')
|
Part.objects.create(name='Hello', description='A thing', IPN='IPN123', revision='B')
|
||||||
|
|
||||||
# And attempt again with the same values (should fail)
|
# And attempt again with the same values (should fail)
|
||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
Part.objects.create(name='Hello', description='A thing', IPN='IPN123', revision='B')
|
part = Part(name='Hello', description='A thing', IPN='IPN123', revision='B')
|
||||||
|
part.validate_unique()
|
||||||
|
|
||||||
# Now update the settings so duplicate IPN values are *not* allowed
|
# Now update the settings so duplicate IPN values are *not* allowed
|
||||||
InvenTreeSetting.set_setting('PART_ALLOW_DUPLICATE_IPN', False, self.user)
|
InvenTreeSetting.set_setting('PART_ALLOW_DUPLICATE_IPN', False, self.user)
|
||||||
|
|
||||||
with self.assertRaises(ValidationError):
|
with self.assertRaises(ValidationError):
|
||||||
Part.objects.create(name='Hello', description='A thing', IPN='IPN123', revision='C')
|
part = Part(name='Hello', description='A thing', IPN='IPN123', revision='C')
|
||||||
|
part.full_clean()
|
||||||
|
Loading…
Reference in New Issue
Block a user