Ejemplo n.º 1
0
    def test_owner_gets_402_on_expired_project(self):
        auth = UserAuth.objects.create_user(username='******', password='******')
        owner = auth.profile
        project = Project.objects.create(slug='test-slug', title='test title', location='test location', owner=owner, public=False, expires_at=datetime(1970, 1, 1, tzinfo=utc))

        kwargs = {
            'owner_slug': owner.slug,
            'project_slug': project.slug
        }

        url = reverse('app-project-editor', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = auth
        response = project_editor_view(request, **kwargs)

        assert_equal(response.status_code, 402)
Ejemplo n.º 2
0
    def test_owner_gets_editable_details_on_non_public_project(self):
        auth = UserAuth.objects.create_user(username='******', password='******')
        owner = auth.profile
        project = Project.objects.create(slug='test-slug', title='test title', location='test location', owner=owner, public=False)

        kwargs = {
            'owner_slug': owner.slug,
            'project_slug': project.slug
        }

        url = reverse('app-project-editor', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = auth
        response = project_editor_view(request, **kwargs)

        assert_equal(response.status_code, 200)
        assert_equal(response.context_data.get('is_editable'), True)
Ejemplo n.º 3
0
    def test_non_owner_gets_404_on_non_public_project(self):
        owner = Profile.objects.create(slug='mjumbewu')
        project = Project.objects.create(slug='test-slug', title='test title', location='test location', owner=owner, public=False)

        kwargs = {
            'owner_slug': owner.slug,
            'project_slug': project.slug
        }

        auth2 = UserAuth.objects.create_user(username='******', password='******')

        url = reverse('app-project-editor', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = auth2

        with assert_raises(Http404):
            response = project_editor_view(request, **kwargs)
Ejemplo n.º 4
0
    def test_anon_gets_redirect_to_signin_non_public_project(self):
        owner = Profile.objects.create(slug='mjumbewu')
        project = Project.objects.create(slug='test-slug', title='test title', location='test location', owner=owner, public=False)

        kwargs = {
            'owner_slug': owner.slug,
            'project_slug': project.slug
        }

        url = reverse('app-project-editor', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = AnonymousUser()
        response = project_editor_view(request, **kwargs)

        signin_url = reverse('app-signin') + '?next=' + url
        assert_equal(response.status_code, 302)
        assert_equal(response.url, signin_url)
Ejemplo n.º 5
0
    def test_non_owner_gets_404_on_non_public_project(self):
        owner = Profile.objects.create(slug='mjumbewu')
        project = Project.objects.create(slug='test-slug',
                                         title='test title',
                                         location='test location',
                                         owner=owner,
                                         public=False)

        kwargs = {'owner_slug': owner.slug, 'project_slug': project.slug}

        auth2 = UserAuth.objects.create_user(username='******', password='******')

        url = reverse('app-project-editor', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = auth2

        with assert_raises(Http404):
            response = project_editor_view(request, **kwargs)
Ejemplo n.º 6
0
    def test_anon_gets_redirect_to_signin_non_public_project(self):
        owner = Profile.objects.create(slug='mjumbewu')
        project = Project.objects.create(slug='test-slug',
                                         title='test title',
                                         location='test location',
                                         owner=owner,
                                         public=False)

        kwargs = {'owner_slug': owner.slug, 'project_slug': project.slug}

        url = reverse('app-project-editor', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = AnonymousUser()
        response = project_editor_view(request, **kwargs)

        signin_url = reverse('app-signin') + '?next=' + url
        assert_equal(response.status_code, 302)
        assert_equal(response.url, signin_url)
Ejemplo n.º 7
0
    def test_owner_gets_editable_details_on_non_public_project(self):
        auth = UserAuth.objects.create_user(username='******',
                                            password='******')
        owner = auth.profile
        project = Project.objects.create(slug='test-slug',
                                         title='test title',
                                         location='test location',
                                         owner=owner,
                                         public=False)

        kwargs = {'owner_slug': owner.slug, 'project_slug': project.slug}

        url = reverse('app-project-editor', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = auth
        response = project_editor_view(request, **kwargs)

        assert_equal(response.status_code, 200)
        assert_equal(response.context_data.get('is_editable'), True)
Ejemplo n.º 8
0
    def test_owner_gets_402_on_expired_project(self):
        auth = UserAuth.objects.create_user(username='******',
                                            password='******')
        owner = auth.profile
        project = Project.objects.create(slug='test-slug',
                                         title='test title',
                                         location='test location',
                                         owner=owner,
                                         public=False,
                                         expires_at=datetime(1970,
                                                             1,
                                                             1,
                                                             tzinfo=utc))

        kwargs = {'owner_slug': owner.slug, 'project_slug': project.slug}

        url = reverse('app-project-editor', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = auth
        response = project_editor_view(request, **kwargs)

        assert_equal(response.status_code, 402)