Changeset - 671a0bf3b7f7
[Not reviewed]
default
0 1 0
Branko Majic (branko) - 11 years ago 2013-06-25 23:38:44
branko@majic.rs
Added representation tests for Entity. Added representation tests for Interface.
1 file changed with 34 insertions and 0 deletions:
0 comments (0 inline, 0 general)
conntrackt/tests/test_models.py
Show inline comments
 
@@ -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)
0 comments (0 inline, 0 general)