Changeset - 1009b1cbc3de
[Not reviewed]
default
0 1 0
Branko Majic (branko) - 11 years ago 2013-07-24 20:45:06
branko@majic.rs
Noticket: PEP8 fixes.
1 file changed with 3 insertions and 4 deletions:
0 comments (0 inline, 0 general)
conntrackt/tests/test_views.py
Show inline comments
 
@@ -113,25 +113,25 @@ class ProjectViewTest(PermissionTestMixi
 
        # Get the view.
 
        view = ProjectView.as_view()
 

	
 
        # Get the response.
 
        response = generate_get_response(view, pk=1)
 

	
 
        # Fetch context data from response.
 
        location, entities = response.context_data["location_entities"][0]
 

	
 
        # Set-up expected context data values.
 
        expected_entities = ["<Entity: Test Entity 1 (Test Project 1 - Test Location 1)>",
 
                             "<Entity: Test Entity 2 (Test Project 1 - Test Location 1)>"]
 
        
 

	
 
        # Validate context data.
 
        self.assertEqual(location.name, "Test Location 1")
 
        self.assertQuerysetEqual(entities, expected_entities)
 

	
 
        # Fetch context data from response.
 
        location, entities = response.context_data["location_entities"][1]
 

	
 
        # Set-up expected context data values.
 
        expected_entities = ["<Entity: Test Entity 3 (Test Project 1 - Test Location 2)>",
 
                             "<Entity: Test Subnet (Test Project 1 - Test Location 2)>"]
 

	
 
        # Validate context data.
 
@@ -165,25 +165,24 @@ class EntityViewTest(PermissionTestMixin
 
        expected_entity = Entity.objects.get(pk=1)
 

	
 
        expected_incoming_communications = ["<Communication: Test Entity 2 -> Test Entity 1 (TCP:22)>",
 
                                            "<Communication: Test Entity 2 -> Test Entity 1 (ICMP:8)>",
 
                                            "<Communication: Test Entity 3 -> Test Entity 1 (TCP:3306)>",
 
                                            "<Communication: Test Subnet -> Test Entity 1 (TCP:22)>"]
 

	
 
        expected_outgoing_communications = ["<Communication: Test Entity 1 -> Test Entity 2 (UDP:123)>",
 
                                            "<Communication: Test Entity 1 -> Test Entity 3 (UDP:53)>"]
 

	
 
        expected_interfaces = ["<Interface: Test Entity 1 (192.168.1.1)>"]
 

	
 

	
 
        # Validate the response.
 
        self.assertQuerysetEqual(response.context_data["interfaces"], expected_interfaces)
 
        self.assertQuerysetEqual(response.context_data["incoming_communications"], expected_incoming_communications)
 
        self.assertQuerysetEqual(response.context_data["outgoing_communications"], expected_outgoing_communications)
 
        self.assertEqual(response.context_data["entity"], expected_entity)
 
        self.assertTrue("entity_iptables" in response.context_data)
 

	
 

	
 
class EntityIptablesTest(PermissionTestMixin, TestCase):
 

	
 
    fixtures = ['test-data.json']
 

	
 
@@ -476,41 +475,41 @@ class ProjectDeleteViewTest(PermissionTe
 
        request._messages = FakeMessages()
 

	
 
        # Get the response.
 
        response = view(request, pk=1)
 

	
 
        self.assertIn("Project Test Project 1 has been removed.", request._messages.messages)
 

	
 

	
 
class LocationCreateViewTest(PermissionTestMixin, TestCase):
 

	
 
    view_class = LocationCreateView
 
    sufficient_permissions = ("add_location",)
 
 
 

	
 
    def test_form_styling(self):
 
        """
 
        Tests if proper form styling is being applied.
 
        """
 

	
 
        # Get the view.
 
        view = LocationCreateView.as_view()
 

	
 
        # Get the response.
 
        response = generate_get_response(view)
 

	
 
        self.assertContains(response, 'class="span6 textinput')
 
        self.assertContains(response, 'class="span6 textarea')
 
        self.assertContains(response, 'placeholder="New Location"')
 
        self.assertContains(response, 'placeholder="Description for new location."')
 
        
 

	
 

	
 
class LocationUpdateViewTest(PermissionTestMixin, TestCase):
 

	
 
    fixtures = ['test-data.json']
 

	
 
    view_class = LocationUpdateView
 
    sufficient_permissions = ("change_location",)
 
    permission_test_view_kwargs = {"pk": 1}
 

	
 
    def test_form_styling(self):
 
        """
 
        Tests if proper form styling is being applied.
0 comments (0 inline, 0 general)