本文整理匯總了Python中common.utilities.inversion_of_control.Dependency.update_team方法的典型用法代碼示例。如果您正苦於以下問題:Python Dependency.update_team方法的具體用法?Python Dependency.update_team怎麽用?Python Dependency.update_team使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類common.utilities.inversion_of_control.Dependency
的用法示例。
在下文中一共展示了Dependency.update_team方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestCoreUserAccess
# 需要導入模塊: from common.utilities.inversion_of_control import Dependency [as 別名]
# 或者: from common.utilities.inversion_of_control.Dependency import update_team [as 別名]
#.........這裏部分代碼省略.........
# reset mocks & stubs
m.ResetAll()
m.UnsetStubs()
m.StubOutWithMock(utils, "encrypt_password")
m.StubOutWithMock(utils, "verify_password")
m.StubOutWithMock(base64, "b64encode")
m.StubOutWithMock(os, "urandom")
utils.encrypt_password("yoda").AndReturn("the force")
utils.verify_password("yoda", None).AndReturn(True)
# mock the urandom return for the salt, and make sure that gets base-64 encoded into something different
os.urandom(128).AndReturn("obi-wan")
base64.b64encode("obi-wan").AndReturn("darth vader")
m.ReplayAll()
updated_user = self.user_access.update_user(user["id"], {"password": "yoda"})
# we should have "encrypted" the password "yoda" to "the force", and added a new salt
self.assertEqual(updated_user["password"], "the force")
self.assertEqual(updated_user["salt"], "darth vader")
def test_team_basic_crud(self):
team_dict = self.__get_team_dict()
team = self.user_access.create_team(team_dict)
self.assertIn("id", team)
self.assertEqual(team_dict["name"], team["name"])
self.assertEqual(team_dict["description"], team["description"])
self.assertEqual(team_dict["is_generalist"], team["is_generalist"])
team2 = self.user_access.update_team(team["id"], {"name": "asdfasdf"})
self.assertEqual(team2["name"], "asdfasdf")
self.assertEqual(team2["id"], team["id"])
team3 = self.user_access.get_team(team2["id"])
self.assertEqual(team2, team3)
result = self.user_access.delete_team(team3["id"])
self.assertEqual(result, True)
no_team = self.user_access.get_team(team2["id"])
self.assertEqual(no_team, None)
def test_team_create_with_users_and_industries(self):
# create stub
m = Mox()
m.StubOutWithMock(utils, "encrypt_password")
m.StubOutWithMock(base64, "b64encode")
# start recording
# can't seem to stub os.urandom here... returns None sometimes?
base64.b64encode(IsA(str)).AndReturn("Larry")
utils.encrypt_password("test")
base64.b64encode(IsA(str)).AndReturn("Moe")
utils.encrypt_password("test")
base64.b64encode(IsA(str)).AndReturn("Curly")
utils.encrypt_password("test")
m.ReplayAll()