|
@@ -392,24 +392,25 @@ class ProjectUpdateViewTest(PermissionTe
|
|
|
"""
|
|
|
Verifies that the context is properly set-up when the view is called for
|
|
|
specific project.
|
|
|
"""
|
|
|
|
|
|
# Get the view.
|
|
|
view = ProjectUpdateView.as_view()
|
|
|
|
|
|
# Get the response.
|
|
|
response = generate_get_response(view, None, pk=1)
|
|
|
|
|
|
self.assertEqual(response.context_data["project"].name, "Test Project 1")
|
|
|
self.assertEqual(response.context_data["headline"], "Update project Test Project 1")
|
|
|
|
|
|
|
|
|
class ProjectDeleteViewTest(PermissionTestMixin, TestCase):
|
|
|
|
|
|
fixtures = ['test-data.json']
|
|
|
|
|
|
view_class = ProjectDeleteView
|
|
|
sufficient_permissions = ("delete_project",)
|
|
|
permission_test_view_kwargs = {"pk": "1"}
|
|
|
|
|
|
def test_context(self):
|
|
|
"""
|
|
@@ -418,24 +419,25 @@ class ProjectDeleteViewTest(PermissionTe
|
|
|
"""
|
|
|
|
|
|
# Get the expected project.
|
|
|
project = Project.objects.get(pk=1)
|
|
|
|
|
|
# Get the view.
|
|
|
view = ProjectDeleteView.as_view()
|
|
|
|
|
|
# Get the response.
|
|
|
response = generate_get_response(view, None, pk=1)
|
|
|
|
|
|
self.assertEqual(response.context_data["project"], project)
|
|
|
self.assertEqual(response.context_data["headline"], "Delete project Test Project 1")
|
|
|
|
|
|
def test_message(self):
|
|
|
"""
|
|
|
Tests if the message gets added when the project is deleted.
|
|
|
"""
|
|
|
|
|
|
# Get the view.
|
|
|
view = ProjectDeleteView.as_view()
|
|
|
|
|
|
# Generate the request.
|
|
|
request = RequestFactory().post("/fake-path/")
|
|
|
request.user = mock.Mock()
|
|
@@ -466,24 +468,25 @@ class LocationUpdateViewTest(PermissionT
|
|
|
"""
|
|
|
Verifies that the context is properly set-up when the view is called for
|
|
|
specific location.
|
|
|
"""
|
|
|
|
|
|
# Get the view.
|
|
|
view = LocationUpdateView.as_view()
|
|
|
|
|
|
# Get the response.
|
|
|
response = generate_get_response(view, None, pk=1)
|
|
|
|
|
|
self.assertEqual(response.context_data["location"].name, "Test Location 1")
|
|
|
self.assertEqual(response.context_data["headline"], "Update location Test Location 1")
|
|
|
|
|
|
|
|
|
class LocationDeleteViewTest(PermissionTestMixin, TestCase):
|
|
|
|
|
|
fixtures = ['test-data.json']
|
|
|
|
|
|
view_class = LocationDeleteView
|
|
|
sufficient_permissions = ("delete_location",)
|
|
|
permission_test_view_kwargs = {"pk": "1"}
|
|
|
|
|
|
def test_context(self):
|
|
|
"""
|
|
@@ -492,24 +495,25 @@ class LocationDeleteViewTest(PermissionT
|
|
|
"""
|
|
|
|
|
|
# Get the expected location.
|
|
|
location = Location.objects.get(pk=1)
|
|
|
|
|
|
# Get the view.
|
|
|
view = LocationDeleteView.as_view()
|
|
|
|
|
|
# Get the response.
|
|
|
response = generate_get_response(view, None, pk=1)
|
|
|
|
|
|
self.assertEqual(response.context_data["location"], location)
|
|
|
self.assertEqual(response.context_data["headline"], "Delete location Test Location 1")
|
|
|
|
|
|
def test_message(self):
|
|
|
"""
|
|
|
Tests if the message gets added when the location is deleted.
|
|
|
"""
|
|
|
|
|
|
# Get the view.
|
|
|
view = LocationDeleteView.as_view()
|
|
|
|
|
|
# Generate the request.
|
|
|
request = RequestFactory().post("/fake-path/")
|
|
|
request.user = mock.Mock()
|
|
@@ -615,24 +619,25 @@ class EntityDeleteViewTest(PermissionTes
|
|
|
"""
|
|
|
|
|
|
# Get the expected entity.
|
|
|
entity = Entity.objects.get(pk=1)
|
|
|
|
|
|
# Get the view.
|
|
|
view = EntityDeleteView.as_view()
|
|
|
|
|
|
# Get the response.
|
|
|
response = generate_get_response(view, None, pk=1)
|
|
|
|
|
|
self.assertEqual(response.context_data["entity"], entity)
|
|
|
self.assertEqual(response.context_data["headline"], "Delete entity Test Entity 1")
|
|
|
|
|
|
def test_message(self):
|
|
|
"""
|
|
|
Tests if the message gets added when the entity is deleted.
|
|
|
"""
|
|
|
|
|
|
# Get the view.
|
|
|
view = EntityDeleteView.as_view()
|
|
|
|
|
|
# Generate the request.
|
|
|
request = RequestFactory().post("/fake-path/")
|
|
|
request.user = mock.Mock()
|
|
@@ -677,24 +682,25 @@ class EntityUpdateViewTest(PermissionTes
|
|
|
"""
|
|
|
Verifies that the context is properly set-up when the view is called for
|
|
|
specific entity.
|
|
|
"""
|
|
|
|
|
|
# Get the view.
|
|
|
view = EntityUpdateView.as_view()
|
|
|
|
|
|
# Get the response.
|
|
|
response = generate_get_response(view, None, pk=1)
|
|
|
|
|
|
self.assertEqual(response.context_data["entity"].name, "Test Entity 1")
|
|
|
self.assertEqual(response.context_data["headline"], "Update entity Test Entity 1")
|
|
|
|
|
|
|
|
|
class InterfaceCreateViewTest(PermissionTestMixin, TestCase):
|
|
|
|
|
|
view_class = InterfaceCreateView
|
|
|
sufficient_permissions = ("add_interface",)
|
|
|
|
|
|
def setUp(self):
|
|
|
"""
|
|
|
Sets-up some data necessary for testing.
|
|
|
"""
|
|
|
|
|
@@ -773,24 +779,25 @@ class InterfaceUpdateViewTest(Permission
|
|
|
"""
|
|
|
|
|
|
# Get the view.
|
|
|
view = InterfaceUpdateView.as_view()
|
|
|
|
|
|
# Get the response.
|
|
|
response = generate_get_response(view, None, pk=1)
|
|
|
|
|
|
# Set-up expected interface.
|
|
|
interface = Interface.objects.get(pk=1)
|
|
|
|
|
|
self.assertEqual(response.context_data["interface"], interface)
|
|
|
self.assertEqual(response.context_data["headline"], "Update interface eth0")
|
|
|
|
|
|
def test_form_entity_limit(self):
|
|
|
"""
|
|
|
Tests if the queryset is properly limitted to specific project's
|
|
|
entities.
|
|
|
"""
|
|
|
|
|
|
# Set-up the view.
|
|
|
view = InterfaceUpdateView()
|
|
|
view.request = RequestFactory().get("/fake-path/1")
|
|
|
view.object = Interface.objects.get(pk=1)
|
|
|
|
|
@@ -845,24 +852,25 @@ class InterfaceDeleteViewTest(Permission
|
|
|
"""
|
|
|
|
|
|
# Get the expected entity.
|
|
|
interface = Interface.objects.get(pk=1)
|
|
|
|
|
|
# Get the view.
|
|
|
view = InterfaceDeleteView.as_view()
|
|
|
|
|
|
# Get the response.
|
|
|
response = generate_get_response(view, None, pk=1)
|
|
|
|
|
|
self.assertEqual(response.context_data["interface"], interface)
|
|
|
self.assertEqual(response.context_data["headline"], "Delete interface eth0")
|
|
|
|
|
|
def test_message(self):
|
|
|
"""
|
|
|
Tests if the message gets added when the interface is deleted.
|
|
|
"""
|
|
|
|
|
|
# Get the view.
|
|
|
view = InterfaceDeleteView.as_view()
|
|
|
|
|
|
# Generate the request.
|
|
|
request = RequestFactory().post("/fake-path/")
|
|
|
request.user = mock.Mock()
|
|
@@ -1131,24 +1139,25 @@ class CommunicationUpdateViewTest(Permis
|
|
|
"""
|
|
|
|
|
|
# Get the view.
|
|
|
view = CommunicationUpdateView.as_view()
|
|
|
|
|
|
# Get the response.
|
|
|
response = generate_get_response(view, None, pk=1)
|
|
|
|
|
|
# Set-up expected interface.
|
|
|
communication = Communication.objects.get(pk=1)
|
|
|
|
|
|
self.assertEqual(response.context_data["communication"], communication)
|
|
|
self.assertEqual(response.context_data["headline"], "Update communication Test Entity 2 -> Test Entity 1 (TCP:22)")
|
|
|
|
|
|
def test_form_interface_limit(self):
|
|
|
"""
|
|
|
Tests if the queryset is properly limitted to specific project's
|
|
|
entity interfaces.
|
|
|
"""
|
|
|
|
|
|
# Set-up the view.
|
|
|
view = CommunicationUpdateView()
|
|
|
view.request = RequestFactory().get("/fake-path/1")
|
|
|
view.object = Communication.objects.get(pk=1)
|
|
|
|
|
@@ -1233,24 +1242,25 @@ class CommunicationDeleteViewTest(Permis
|
|
|
"""
|
|
|
|
|
|
# Get the expected entity.
|
|
|
communication = Communication.objects.get(pk=1)
|
|
|
|
|
|
# Get the view.
|
|
|
view = CommunicationDeleteView.as_view()
|
|
|
|
|
|
# Get the response.
|
|
|
response = generate_get_response(view, None, pk=1)
|
|
|
|
|
|
self.assertEqual(response.context_data["communication"], communication)
|
|
|
self.assertEqual(response.context_data["headline"], "Delete communication Test Entity 2 -> Test Entity 1 (TCP:22)")
|
|
|
|
|
|
def test_message(self):
|
|
|
"""
|
|
|
Tests if the message gets added when the communication is deleted.
|
|
|
"""
|
|
|
|
|
|
# Get the view.
|
|
|
view = CommunicationDeleteView.as_view()
|
|
|
|
|
|
# Generate the request.
|
|
|
request = RequestFactory().post("/fake-path/")
|
|
|
request.user = mock.Mock()
|