Exemplo n.º 1
0
 def test_non_existant_404(self):
     """Test that a UUID that does not exist causes a 404"""
     view = views.UserDetailView()
     view.kwargs = {'user_uuid': 'does-not-exist'}
     with self.assertRaises(Http404):
         # pylint: disable=W0104
         view.user
Exemplo n.º 2
0
 def test_get_object_user_is_banned_no_permission_to_view_profile(self):
     """should raise Http404 if user is banned and you don't have perms."""
     user = mommy.make('accounts.User', is_banned=True)
     view = views.UserDetailView()
     view.request = self.request_factory.get('/')
     view.request.user = self.create_user(is_staff=True)
     view.kwargs = {'user_uuid': user.uuid}
     self.assertRaises(Http404, view.get_object)
Exemplo n.º 3
0
 def test_get_object(self):
     """get_object should return the correct user."""
     view = views.UserDetailView()
     view.request = self.request_factory.get('/')
     user = self.create_user()
     view.request.user = user
     view.kwargs = {'user_uuid': user.uuid}
     self.assertEqual(view.get_object(), user)
Exemplo n.º 4
0
 def test_get_object_user_is_banned(self, mock_messages):
     """should return the user and add a warning if user is banned."""
     user = mommy.make('accounts.User', is_banned=True)
     view = views.UserDetailView()
     view.request = self.request
     view.request.user = self.create_superuser()
     view.kwargs = {'user_uuid': user.uuid}
     self.assertEqual(view.get_object(), user)
     self.assertEqual(mock_messages.warning.call_args_list[0][0][1],
                      'This is a banned account.')
Exemplo n.º 5
0
 def test_user_property(self):
     """Test that the user property returns the user."""
     view = views.UserDetailView()
     user = self.create_user()
     view.kwargs = {'user_uuid': user.uuid}
     self.assertEqual(view.user, user)