Clean up unique on existing models
This commit is contained in:
parent
a44ac2fa81
commit
49eacdeef4
16 changed files with 141 additions and 12 deletions
|
@ -26,6 +26,13 @@ class SiteTestCase(TestCase):
|
|||
self.assertTrue(isinstance(s, Site))
|
||||
self.assertEqual(s.__str__(), s.name)
|
||||
|
||||
def test_uniqueness(self):
|
||||
s1 = SiteFactory()
|
||||
with transaction.atomic(), self.assertRaises(IntegrityError):
|
||||
SiteFactory(region=s1.region, name=s1.name, code=s1.code)
|
||||
s3 = SiteFactory()
|
||||
self.assertTrue(isinstance(s3, Site))
|
||||
|
||||
|
||||
class MunicipalLocationTestCase(TestCase):
|
||||
def test_creation(self):
|
||||
|
@ -33,6 +40,13 @@ class MunicipalLocationTestCase(TestCase):
|
|||
self.assertTrue(isinstance(m, MunicipalLocation))
|
||||
self.assertEqual(m.__str__(), m.name)
|
||||
|
||||
def test_uniqueness(self):
|
||||
m1 = MunicipalLocationFactory()
|
||||
with transaction.atomic(), self.assertRaises(IntegrityError):
|
||||
MunicipalLocationFactory(name=m1.name, code=m1.code)
|
||||
m3 = MunicipalLocationFactory()
|
||||
self.assertTrue(isinstance(m3, MunicipalLocation))
|
||||
|
||||
|
||||
class StudyLocationTestCase(TestCase):
|
||||
def test_creation(self):
|
||||
|
@ -54,5 +68,11 @@ class StorageLocationTestCase(TestCase):
|
|||
self.assertTrue(isinstance(s, StorageLocation))
|
||||
self.assertEqual(s.__str__(), s.code)
|
||||
|
||||
|
||||
|
||||
def test_uniqueness(self):
|
||||
s1 = StorageLocationFactory()
|
||||
with transaction.atomic(), self.assertRaises(IntegrityError):
|
||||
StorageLocationFactory(code=s1.code, facility=s1.facility,
|
||||
building=s1.building, room=s1.room,
|
||||
freezer=s1.freezer, temp_c=s1.temp_c)
|
||||
s3 = StorageLocationFactory()
|
||||
self.assertTrue(isinstance(s3, StorageLocation))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue