Ejemplo n.º 1
0
 def test_register_set_admin(self):
     """ If access needs admin, first registered user is set as admin """
     self.request.named_subpaths = {'username': '******'}
     self.access.need_admin.return_value = True
     api.register(self.request, 'b')
     self.access.register.assert_called_with('a', 'b')
     self.access.approve_user.assert_called_with('a')
     self.access.set_user_admin.assert_called_with('a', True)
Ejemplo n.º 2
0
 def test_register(self):
     """ Registration registers user with access backend """
     self.request.named_subpaths = {'username': '******'}
     self.access.need_admin.return_value = False
     self.access.user_data.return_value = None
     self.access.pending_users.return_value = []
     api.register(self.request, 'b')
     self.access.register.assert_called_with('a', 'b')
Ejemplo n.º 3
0
 def test_register_set_admin(self):
     """ If access needs admin, first registered user is set as admin """
     self.request.named_subpaths = {'username': '******'}
     self.access.need_admin.return_value = True
     api.register(self.request, 'b')
     self.access.register.assert_called_with('a', 'b')
     self.access.approve_user.assert_called_with('a')
     self.access.set_user_admin.assert_called_with('a', True)
Ejemplo n.º 4
0
 def test_register_set_admin(self):
     """If access needs admin, first registered user is set as admin"""
     self.request.named_subpaths = {"username": "******"}
     self.access.need_admin.return_value = True
     self.access.user_data.return_value = None
     self.access.pending_users.return_value = []
     api.register(self.request, "b")
     self.access.register.assert_called_with("a", "b")
     self.access.approve_user.assert_called_with("a")
     self.access.set_user_admin.assert_called_with("a", True)
Ejemplo n.º 5
0
 def test_register_not_allowed(self):
     """ If registration is disabled, register() returns 404 """
     self.request.named_subpaths = {'username': '******'}
     self.access.allow_register.return_value = False
     self.access.need_admin.return_value = False
     ret = api.register(self.request, 'b')
     self.assertTrue(isinstance(ret, HTTPForbidden))
Ejemplo n.º 6
0
 def test_register_not_allowed(self):
     """ If registration is disabled, register() returns 404 """
     self.request.named_subpaths = {'username': '******'}
     self.access.allow_register = False
     self.access.need_admin.return_value = False
     ret = api.register(self.request, 'b')
     self.assertTrue(isinstance(ret, HTTPNotFound))
Ejemplo n.º 7
0
 def test_register(self):
     """ Registration registers user with access backend """
     self.request.named_subpaths = {'username': '******'}
     self.access.need_admin.return_value = False
     api.register(self.request, 'b')
     self.access.register.assert_called_with('a', 'b')