|
@@ -15,7 +15,7 @@ from django.test import TestCase
|
|
|
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
|
|
@@ -1332,3 +1332,53 @@ class CommunicationDeleteViewTest(Permis
|
|
|
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")
|