File diff 9b889983cd7b → 49f356923784
conntrackt/tests/test_views.py
Show inline comments
 
@@ -12,13 +12,13 @@ from django.test import RequestFactory
 
from django.test import TestCase
 

	
 
# Application imports
 
from conntrackt.models import Project, Location, Entity, Interface, Communication
 

	
 
from conntrackt.views import IndexView
 
from conntrackt.views import entity_iptables, project_iptables
 
from conntrackt.views import entity_iptables, project_iptables, project_diagram
 

	
 
from conntrackt.views import ProjectView, ProjectCreateView, ProjectUpdateView, ProjectDeleteView
 
from conntrackt.views import LocationCreateView, LocationUpdateView, LocationDeleteView
 
from conntrackt.views import EntityView, EntityCreateView, EntityUpdateView, EntityDeleteView
 
from conntrackt.views import InterfaceCreateView, InterfaceUpdateView, InterfaceDeleteView
 
from conntrackt.views import CommunicationCreateView, CommunicationUpdateView, CommunicationDeleteView
 
@@ -1329,6 +1329,56 @@ class CommunicationDeleteViewTest(Permis
 
        request._messages = FakeMessages()
 

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

	
 
        self.assertEqual(response["Location"], reverse("entity", args=(communication.source.entity.pk,)))
 

	
 

	
 
class ProjectDiagramTest(PermissionTestMixin, TestCase):
 

	
 
    fixtures = ['test-data.json']
 

	
 
    view_function = staticmethod(project_diagram)
 
    sufficient_permissions = ("view",)
 
    permission_test_view_kwargs = {"pk": "1"}
 

	
 
    def test_invalid_project(self):
 
        """
 
        Tests if a 404 is returned if no project was found (invalid ID).
 
        """
 

	
 
        # Set-up a request.
 
        request = create_get_request()
 

	
 
        # Get the view.
 
        view = project_diagram
 

	
 
        # Validate the response.
 
        self.assertRaises(Http404, view, request, pk=200)
 

	
 
    def test_content_type(self):
 
        """
 
        Test if correct content type is being returned by the response.
 
        """
 

	
 
        # Get the view.
 
        view = project_diagram
 

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

	
 
        self.assertEqual(response['Content-Type'], "image/svg+xml")
 

	
 
    def test_content(self):
 
        """
 
        Tests content produced by the view.
 
        """
 

	
 
        # Get the view.
 
        view = project_diagram
 

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

	
 
        self.assertContains(response, '"-//W3C//DTD SVG 1.1//EN"')
 
        self.assertContains(response, "Test Project 1")