File diff 49f356923784 → ea8aa73f8ebb
conntrackt/tests/test_views.py
Show inline comments
 
@@ -20,13 +20,16 @@ from conntrackt.views import entity_ipta
 
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
 

	
 
from helpers import PermissionTestMixin, create_get_request, generate_get_response, FakeMessages
 
# Test imports.
 
from .forms import FormWithWidgetCSSClassFormMixin, FormWithPlaceholderFormMixin
 
from .helpers import PermissionTestMixin, create_get_request, generate_get_response, FakeMessages
 
from .views import RedirectToNextMixinView
 

	
 

	
 
class IndexViewTest(PermissionTestMixin, TestCase):
 

	
 
    fixtures = ['test-data.json']
 

	
 
@@ -1379,6 +1382,51 @@ class ProjectDiagramTest(PermissionTestM
 

	
 
        # 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")
 

	
 

	
 
class RedirectToNextMixinTest(TestCase):
 

	
 
    def test_request_with_next(self):
 
        """
 
        Test if the get_success_url returns correct URL if "next" is present in
 
        request's GET parameters.
 
        """
 

	
 
        # Generate the request.
 
        request = RequestFactory().post("/fake-path?next=/next")
 

	
 
        # Initialise the pseudo-view.
 
        view = RedirectToNextMixinView(request)
 

	
 
        self.assertEqual("/next", view.get_success_url())
 

	
 
    def test_request_without_next(self):
 
        """
 
        Test if the get_success_url returns correct URL if "next" is not present
 
        in request's GET parameters.
 
        """
 

	
 
        # Generate the request.
 
        request = RequestFactory().post("/fake-path")
 

	
 
        # Initialise the pseudo-view.
 
        view = RedirectToNextMixinView(request)
 

	
 
        self.assertEqual("/STATIC", view.get_success_url())
 

	
 
    def test_request_custom_parameter_name(self):
 
        """
 
        Test if the mixin honours the custom parameter name.
 
        """
 

	
 
        # Generate the request.
 
        request = RequestFactory().post("/fake-path?custom=/next")
 

	
 
        # Initialise the pseudo-view.
 
        view = RedirectToNextMixinView(request)
 
        view.next_parameter = "custom"
 

	
 
        self.assertEqual("/next", view.get_success_url())