Example #1
0
 def test_user_delete_view(self):
     """ Test the response of the `user_delete` view."""
     self.dummy_user_fixture()
     from anuket.views.user import user_delete_view
     request = AnuketDummyRequest()
     request.matchdict = {'user_id': 1}
     request.referer = '/tools/user'
     response = user_delete_view(request)
     self.assertEqual(response.location, '/tools/user')
     self.assertEqual(request.session.pop_flash('warn')[0],
                      u"User deleted.")
Example #2
0
 def test_user_delete_view(self):
     """ Test the response of the `user_delete` view."""
     self.dummy_user_fixture()
     from anuket.views.user import user_delete_view
     request = AnuketDummyRequest()
     request.matchdict = {'user_id': 1}
     request.referer = '/tools/user'
     response = user_delete_view(request)
     self.assertEqual(response.location, '/tools/user')
     self.assertEqual(
         request.session.pop_flash('warn')[0], u"User deleted.")
Example #3
0
 def test_user_delete_view_of_only_admin_is_forbiden(self):
     """ Test the response of the `user_delete` view wile trying to
     delete the only admin user.
     """
     self.admin_user_fixture()
     from anuket.views.user import user_delete_view
     request = AnuketDummyRequest()
     request.matchdict = {'user_id': 1}
     request.referer = '/tools/user'
     response = user_delete_view(request)
     self.assertEqual(response.location, '/tools/user')
     self.assertEqual(request.session.pop_flash('error')[0],
                      u"Deletion of the only admin forbidden!")
Example #4
0
 def test_user_delete_view_not_exist(self):
     """ Test the response of the `user_delete` view with a non existent
     `user_id`.
     """
     self.dummy_user_fixture()
     from anuket.views.user import user_delete_view
     request = AnuketDummyRequest()
     request.matchdict = {'user_id': 0}
     request.referer = '/tools/user'
     response = user_delete_view(request)
     self.assertEqual(response.location, '/tools/user')
     self.assertEqual(request.session.pop_flash('error')[0],
                      u"This user did not exist!")
Example #5
0
 def test_user_delete_view_not_exist(self):
     """ Test the response of the `user_delete` view with a non existent
     `user_id`.
     """
     self.dummy_user_fixture()
     from anuket.views.user import user_delete_view
     request = AnuketDummyRequest()
     request.matchdict = {'user_id': 0}
     request.referer = '/tools/user'
     response = user_delete_view(request)
     self.assertEqual(response.location, '/tools/user')
     self.assertEqual(
         request.session.pop_flash('error')[0], u"This user did not exist!")
Example #6
0
 def test_user_delete_view_without_referer_is_forbiden(self):
     """ test the response of the `user_delete` view wile trying to
     directly delete an user (with no referer).
     """
     self.config.include('anuket.views.root')  # register the `root` routes
     self.dummy_user_fixture()
     from anuket.views.user import user_delete_view
     request = AnuketDummyRequest()
     request.matchdict = {'user_id': 1}
     request.referer = None
     response = user_delete_view(request)
     self.assertEqual(response.location, '/')
     self.assertEqual(request.session.pop_flash('error')[0],
                      u"Insufficient permissions!")
Example #7
0
 def test_user_delete_view_of_only_admin_is_forbiden(self):
     """ Test the response of the `user_delete` view wile trying to
     delete the only admin user.
     """
     self.admin_user_fixture()
     from anuket.views.user import user_delete_view
     request = AnuketDummyRequest()
     request.matchdict = {'user_id': 1}
     request.referer = '/tools/user'
     response = user_delete_view(request)
     self.assertEqual(response.location, '/tools/user')
     self.assertEqual(
         request.session.pop_flash('error')[0],
         u"Deletion of the only admin forbidden!")
Example #8
0
 def test_user_delete_view_without_referer_is_forbiden(self):
     """ test the response of the `user_delete` view wile trying to
     directly delete an user (with no referer).
     """
     self.config.include('anuket.views.root')  # register the `root` routes
     self.dummy_user_fixture()
     from anuket.views.user import user_delete_view
     request = AnuketDummyRequest()
     request.matchdict = {'user_id': 1}
     request.referer = None
     response = user_delete_view(request)
     self.assertEqual(response.location, '/')
     self.assertEqual(
         request.session.pop_flash('error')[0],
         u"Insufficient permissions!")