# HG changeset patch # User Branko Majic # Date 2013-06-25 23:38:44 # Node ID 671a0bf3b7f77d05a83218801f3fe1df16a295b2 # Parent 30e997a9d6c96e8a4f2d4da803cf3b57f633d5a3 Added representation tests for Entity. Added representation tests for Interface. 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 @@ -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)" + + self.assertEqual(str(interface), representation)