diff --git a/conntrackt/tests/test_models.py b/conntrackt/tests/test_models.py --- a/conntrackt/tests/test_models.py +++ b/conntrackt/tests/test_models.py @@ -146,6 +146,19 @@ class InterfaceTest(TestCase): self.assertRaises(IntegrityError, duplicate.save) + def test_unique_address(self): + """ + Test if unique address/netmask is enforced across same entity. + """ + + entity = Entity.objects.get(pk=1) + + interface = entity.interface_set.get(pk=1) + + duplicate = Interface(name="eth1", description="Duplicate address", entity=entity, address=interface.address, netmask=interface.netmask) + + self.assertRaises(IntegrityError, duplicate.save) + def test_representation_single(self): """ Test representation of single IP address.