def test_ensure_admin_errors(self, client_mock, config_mock): client_mock.who_am_i.return_value = Principal(permissions=[]) config_mock.web.username = None self.assertRaises(ConfigurationError, bg.ensure_admin) config_mock.web.username = "******" self.assertRaises(ConfigurationError, bg.ensure_admin) client_mock.who_am_i.side_effect = ValidationError self.assertRaises(ConfigurationError, bg.ensure_admin)
def bg_principal(principal_dict, bg_role): dict_copy = copy.deepcopy(principal_dict) dict_copy['roles'] = [bg_role] return Principal(**dict_copy)
def principal(self): return Principal(username="******", roles=["bg-admin"], permissions=["bg-all"])
def principal(self): return Principal(username='******', roles=['bg-admin'], permissions=['bg-all'])
def test_ensure_admin(self, client_mock): client_mock.who_am_i.return_value = Principal(permissions=["bg-all"]) bg.ensure_admin()