Ejemplo n.º 1
0
    def test_login_redirect_to_original_referer(self):
        user = UserFactory.create()
        project = ProjectFactory.create()

        view = LocationsAdd.as_view()

        request = HttpRequest()
        referer = '/organizations/{}/projects/{}'.format(
            project.organization.slug, project.slug)
        request.META['HTTP_REFERER'] = referer
        setattr(request, 'user', user)
        setattr(request, 'method', 'GET')

        setattr(request, 'session', 'session')
        self.messages = FallbackStorage(request)
        setattr(request, '_messages', self.messages)

        kwargs = {
            'organization': project.organization.slug,
            'project': project.slug
        }

        response = view(request, **kwargs)
        assert response.status_code == 302
        assert referer == response['location']
Ejemplo n.º 2
0
    def test_login_redirect_to_original_referer(self):
        user = UserFactory.create()
        project = ProjectFactory.create()

        view = LocationsAdd.as_view()

        request = HttpRequest()
        referer = '/organizations/{}/projects/{}'.format(
            project.organization.slug,
            project.slug
        )
        request.META['HTTP_REFERER'] = referer
        setattr(request, 'user', user)
        setattr(request, 'method', 'GET')

        setattr(request, 'session', 'session')
        self.messages = FallbackStorage(request)
        setattr(request, '_messages', self.messages)

        kwargs = {
            'organization': project.organization.slug,
            'project': project.slug
        }

        response = view(request, **kwargs)
        assert response.status_code == 302
        assert referer == response['location']
Ejemplo n.º 3
0
    def test_login_redirect_to_project_dashboard(self):
        user = UserFactory.create()
        project = ProjectFactory.create()

        view = LocationsAdd.as_view()

        request = HttpRequest()
        request.META['HTTP_REFERER'] = '/account/login/'
        setattr(request, 'user', user)
        setattr(request, 'method', 'GET')

        setattr(request, 'session', 'session')
        self.messages = FallbackStorage(request)
        setattr(request, '_messages', self.messages)

        kwargs = {
            'organization': project.organization.slug,
            'project': project.slug
        }

        exp_redirect = reverse('organization:project-dashboard', kwargs=kwargs)
        response = view(request, **kwargs)
        assert response.status_code == 302
        assert exp_redirect == response['location']
Ejemplo n.º 4
0
    def test_login_redirect_to_project_dashboard(self):
        user = UserFactory.create()
        project = ProjectFactory.create()

        view = LocationsAdd.as_view()

        request = HttpRequest()
        request.META['HTTP_REFERER'] = '/account/login/'
        setattr(request, 'user', user)
        setattr(request, 'method', 'GET')

        setattr(request, 'session', 'session')
        self.messages = FallbackStorage(request)
        setattr(request, '_messages', self.messages)

        kwargs = {
            'organization': project.organization.slug,
            'project': project.slug
        }

        exp_redirect = reverse('organization:project-dashboard', kwargs=kwargs)
        response = view(request, **kwargs)
        assert response.status_code == 302
        assert exp_redirect == response['location']