示例#1
0
    def test_anon_gets_redirect_to_signin(self):
        profile = Profile.objects.create(slug='mjumbewu')

        kwargs = {
            'profile_slug': profile.slug,
        }

        url = reverse('app-profile', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = AnonymousUser()
        response = profile_view(request, **kwargs)

        signin_url = reverse('app-signin') + '?next=' + url
        assert_equal(response.status_code, 302)
        assert_equal(response.url, signin_url)
示例#2
0
    def test_anon_gets_redirect_to_signin(self):
        profile = Profile.objects.create(slug='mjumbewu')

        kwargs = {
            'profile_slug': profile.slug,
        }

        url = reverse('app-profile', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = AnonymousUser()
        response = profile_view(request, **kwargs)

        signin_url = reverse('app-signin') + '?next=' + url
        assert_equal(response.status_code, 302)
        assert_equal(response.url, signin_url)
示例#3
0
    def test_non_member_gets_redirect_to_home(self):
        profile = Profile.objects.create(slug='mjumbewu')

        kwargs = {
            'profile_slug': profile.slug,
        }

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

        url = reverse('app-profile', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = auth
        response = profile_view(request, **kwargs)

        home_url = reverse('app-index')
        assert_equal(response.status_code, 302)
        assert_equal(response.url, home_url)
示例#4
0
    def test_non_member_gets_redirect_to_home(self):
        profile = Profile.objects.create(slug='mjumbewu')

        kwargs = {
            'profile_slug': profile.slug,
        }

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

        url = reverse('app-profile', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = auth
        response = profile_view(request, **kwargs)

        home_url = reverse('app-index')
        assert_equal(response.status_code, 302)
        assert_equal(response.url, home_url)
示例#5
0
    def test_member_gets_profile_admin(self):
        profile = Profile.objects.create(slug='mjumbewu')

        kwargs = {
            'profile_slug': profile.slug,
        }

        auth = UserAuth.objects.create_user(username='******', password='******')
        member = auth.profile
        profile.members.add(member)

        url = reverse('app-profile', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = auth
        response = profile_view(request, **kwargs)

        assert_equal(response.status_code, 200)
        assert_in('profile_data', response.context_data)
        assert_equal(response.context_data['profile_data']['slug'], profile.slug)
示例#6
0
    def test_member_gets_profile_admin(self):
        profile = Profile.objects.create(slug='mjumbewu')

        kwargs = {
            'profile_slug': profile.slug,
        }

        auth = UserAuth.objects.create_user(username='******', password='******')
        member = auth.profile
        profile.members.add(member)

        url = reverse('app-profile', kwargs=kwargs)
        request = self.factory.get(url)
        request.user = auth
        response = profile_view(request, **kwargs)

        assert_equal(response.status_code, 200)
        assert_in('profile_data', response.context_data)
        assert_equal(response.context_data['profile_data']['slug'],
                     profile.slug)