本文整理汇总了Python中common.utilities.inversion_of_control.Dependency.delete_role方法的典型用法代码示例。如果您正苦于以下问题:Python Dependency.delete_role方法的具体用法?Python Dependency.delete_role怎么用?Python Dependency.delete_role使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.utilities.inversion_of_control.Dependency
的用法示例。
在下文中一共展示了Dependency.delete_role方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestCoreUserAccess
# 需要导入模块: from common.utilities.inversion_of_control import Dependency [as 别名]
# 或者: from common.utilities.inversion_of_control.Dependency import delete_role [as 别名]
#.........这里部分代码省略.........
team_dict["user_ids"] = [user1["id"], user2["id"], user3["id"]]
team_dict["industry_ids"] = ["asdf1", "asdf2", "asdf3"]
team = self.user_access.create_team(team_dict)
user_teams = self.user_access.find_user_teams({"team_id": team["id"]})
self.assertEqual(len(user_teams), 3)
for user_team in user_teams:
self.assertTrue(user_team["user_id"] in team_dict["user_ids"])
team_industries = self.user_access.find_team_industries({"team_id": team["id"]})
self.assertEqual(len(team_industries), 3)
for team_industry in team_industries:
self.assertTrue(team_industry["industry_id"] in team_dict["industry_ids"])
def test_role_basic_crud(self):
role_dict = self.__get_role_dict()
role = self.user_access.create_role(role_dict)
self.assertIn("id", role)
self.assertEqual(role_dict["name"], role["name"])
self.assertEqual(role_dict["description"], role["description"])
role2 = self.user_access.update_role(role["id"], {"name": "asdfasdf"})
self.assertEqual(role2["name"], "asdfasdf")
self.assertEqual(role2["id"], role["id"])
role3 = self.user_access.get_role(role2["id"])
self.assertEqual(role2, role3)
result = self.user_access.delete_role(role3["id"])
self.assertEqual(result, True)
no_role = self.user_access.get_role(role2["id"])
self.assertEqual(no_role, None)
def test_user_teams(self):
# create stub
m = Mox()
m.StubOutWithMock(utils, "encrypt_password")
m.StubOutWithMock(utils, "verify_password")
m.StubOutWithMock(base64, "b64encode")
m.StubOutWithMock(os, "urandom")
# start recording
utils.encrypt_password("test")
utils.verify_password("test", None).AndReturn(True)
utils.verify_password("asdfasdf", None).AndReturn(False)
# mock the urandom return for the salt, and make sure that gets base-64 encoded into something different
os.urandom(128).AndReturn("she sells sea shells by the sea shore")
base64.b64encode("she sells sea shells by the sea shore").AndReturn("Salt-n-Pepa")
m.ReplayAll()
# Create user and teams
user1 = self.user_access.create_user(self.__get_user_dict())
team1 = self.user_access.create_team(self.__get_team_dict())
team2 = self.user_access.create_team(self.__get_team_dict())
# Add user to teams
team_ids = [team1["id"], team2["id"]]
self.user_access.update_user(user1["id"], {"team_ids": team_ids})
user_teams = self.user_access.find_user_teams({"user_id": user1["id"]})