@@ -68,3 +68,37 @@ class EntityTest(TestCase):
comm = Communication(source=ent1_eth0, destination=ent2_eth0, protocol="BOGUS", port="1234")
self.assertRaises(ValidationError, comm.full_clean)
def test_representation(self):
"""
Test the representation of entity.
ent = Entity.objects.get(name="Test Entity 1")
representation = "Test Entity 1 (Test Project 1 - Test Location 1)"
self.assertEqual(str(ent), representation)
class InterfaceTest(TestCase):
fixtures = ['test-data.json']
def test_representation_single(self):
Test representation of single IP address.
interface = Entity.objects.get(name="Test Entity 1").interface_set.get(name="eth0")
representation = "Test Entity 1 (192.168.1.1)"
self.assertEqual(str(interface), representation)
def test_representation_subnet(self):
Test representation of subnet.
interface = Entity.objects.get(name="Test Subnet").interface_set.get(name="eth0")
representation = "Test Subnet (192.168.2.0/255.255.255.0)"