コード例 #1
0
ファイル: tests.py プロジェクト: rebkwok/flexibeast
    def test_profile_view(self):
        user = mommy.make(User)
        url = reverse('profile:profile')
        request = self.factory.get(url)
        request.user = user
        resp = profile(request)

        self.assertEquals(resp.status_code, 200)
コード例 #2
0
 def test_get_profile(self):
     rf = RequestFactory()
     get_request = rf.get(path='/profile/')
     get_request.user = User.objects.create_user(username='******')
     resolver_match_mock = Mock(url_name='/profile')
     get_request.resolver_match = resolver_match_mock
     response = views.profile(get_request)
     self.assertEqual(response.status_code, 200)
コード例 #3
0
 def test_edit_profile_with_data(self):
     rf = RequestFactory()
     post_request = rf.post(path='/profile/',
                            data={
                                'age': 12,
                                'weight': 48
                            })
     post_request.user = User.objects.create_user(username='******')
     resolver_match_mock = Mock(url_name='/profile')
     post_request.resolver_match = resolver_match_mock
     response = views.profile(post_request)
     self.assertEqual(response.status_code, 200)
コード例 #4
0
ファイル: test_views.py プロジェクト: skeeph/histmap
 def test_profile_anon(self):
     """
     Method checks that anonymous user is redirected to login page
     """
     request = self.factory.get(self.url)
     request.user = AnonymousUser()
     response = views.profile(request)
     self.assertEqual(response.status_code, 302)
     self.assertIn("location", response._headers)
     self.assertIn(reverse("users:login"), response._headers["location"][1])
     self.assertIn("?next={}".format(self.url),
                   response._headers["location"][1])
コード例 #5
0
ファイル: test_views.py プロジェクト: skeeph/histmap
 def test_profile(self):
     """
     Method test if profile view works fine while user is logged in.
     :return:
     """
     request = self.factory.get(self.url)
     request.user = self.user
     response = views.profile(request)
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, self.user_data['first_name'])
     self.assertContains(response, self.user_data['last_name'])
     self.assertContains(response, self.user_data['email'])
コード例 #6
0
ファイル: test_views.py プロジェクト: SixStringsCoder/Shelfio
 def test_superuser(self):
     user = mixer.blend('accounts.User', is_superuser=True)
     req = RequestFactory().get('/')
     req.user = user
     resp = profile(req)
     assert resp.status_code == 200, 'This is only callable by a superuser'
コード例 #7
0
ファイル: test_views.py プロジェクト: SixStringsCoder/Shelfio
 def test_anonymous(self):
     req = RequestFactory().get('/')
     req.user = AnonymousUser()
     resp = profile(req)
     assert 'login' in resp.url, 'Redirect to login page'
コード例 #8
0
 def test_profile_authenticated(self):
     req = RequestFactory().get(reverse('profile'))
     req.user = mixer.blend(User)
     resp = views.profile(req)
     assert resp.status_code == 200, 'Should only be callable by anonymous users'
コード例 #9
0
 def test_profile_anonymous(self):
     req = RequestFactory().get(reverse('profile'))
     req.user = AnonymousUser()
     resp = views.profile(req)
     assert resp.status_code == 302, 'Should redirect anonymous user to login page'
コード例 #10
0
ファイル: tests.py プロジェクト: judy2k/pipsevents
 def _get_response(self, user):
     url = reverse('profile:profile')
     request = self.factory.get(url)
     request.user = user
     return profile(request)