當前位置: 首頁>>代碼示例>>Python>>正文


Python Dependency.find_user_teams方法代碼示例

本文整理匯總了Python中common.utilities.inversion_of_control.Dependency.find_user_teams方法的典型用法代碼示例。如果您正苦於以下問題:Python Dependency.find_user_teams方法的具體用法?Python Dependency.find_user_teams怎麽用?Python Dependency.find_user_teams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在common.utilities.inversion_of_control.Dependency的用法示例。


在下文中一共展示了Dependency.find_user_teams方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestCoreUserAccess

# 需要導入模塊: from common.utilities.inversion_of_control import Dependency [as 別名]
# 或者: from common.utilities.inversion_of_control.Dependency import find_user_teams [as 別名]

#.........這裏部分代碼省略.........
        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()

        user1 = self.user_access.create_user(self.__get_user_dict())
        user2 = self.user_access.create_user(self.__get_user_dict())
        user3 = self.user_access.create_user(self.__get_user_dict())

        team_dict = self.__get_team_dict()
        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)
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:70,代碼來源:test_core_user_access.py


注:本文中的common.utilities.inversion_of_control.Dependency.find_user_teams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。