File diff 49f356923784 → ea8aa73f8ebb
conntrackt/tests/test_views.py
Show inline comments
 
@@ -23,7 +23,10 @@ from conntrackt.views import EntityView,
 
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):
 
@@ -1382,3 +1385,48 @@ class ProjectDiagramTest(PermissionTestM
 

	
 
        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())