当前位置: 首页>>代码示例>>Python>>正文


Python Dependency.get_user_industries方法代码示例

本文整理汇总了Python中common.utilities.inversion_of_control.Dependency.get_user_industries方法的典型用法代码示例。如果您正苦于以下问题:Python Dependency.get_user_industries方法的具体用法?Python Dependency.get_user_industries怎么用?Python Dependency.get_user_industries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.utilities.inversion_of_control.Dependency的用法示例。


在下文中一共展示了Dependency.get_user_industries方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestCoreUserAccess

# 需要导入模块: from common.utilities.inversion_of_control import Dependency [as 别名]
# 或者: from common.utilities.inversion_of_control.Dependency import get_user_industries [as 别名]

#.........这里部分代码省略.........
        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())

        industry_id1 = self.__get_industry_id()
        industry_id2 = self.__get_industry_id()

        # Add user to teams
        team_ids = [team1["id"], team2["id"]]
        self.user_access.update_user(user1["id"], {"team_ids": team_ids})

        industry_ids = [industry_id1, industry_id2]
        self.user_access.update_team(team1["id"], {"industry_ids": industry_ids})

        team_industries = self.user_access.find_team_industries({"team_id": team1["id"]})
        industry_id_list = [team_industry["industry_id"] for team_industry in team_industries]
        self.assertEqual(industry_id_list, industry_ids)

        user_industry_list = self.user_access.get_user_industries(user1["id"])
        self.assertEqual(user_industry_list, industry_ids)


    def test_create_team__new_team__with_industries(self):
        """
        Tests that the create team works as expected.
        Added as a test for RET-1102
        """
        # create various mock items
        mock_team = {
            "id": "chicken_woot",
            "name": "woot",
            "description": "chicken",
            "is_generalist": False,
            "user_ids": ["yoyoma"],
            "industry_ids": ["danger_zone"]
        }

        # stub several functions
        self.mox.StubOutWithMock(self.user_access, "find_team")
        self.user_access.datastore = self.mox.CreateMockAnything()
        self.mox.StubOutWithMock(self.user_access, "_update_team_users")
        self.mox.StubOutWithMock(self.user_access, "_update_team_industries")

        # record
        self.user_access.find_team({ "name": "woot" })
        self.user_access.datastore.create_team(name = "woot", description = "chicken", is_generalist = False).AndReturn(mock_team)
        self.user_access._update_team_users("chicken_woot", ["yoyoma"])
        self.user_access._update_team_industries("chicken_woot", ["danger_zone"])

        # replay
        self.mox.ReplayAll()
开发者ID:erezrubinstein,项目名称:aa,代码行数:70,代码来源:test_core_user_access.py


注:本文中的common.utilities.inversion_of_control.Dependency.get_user_industries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。