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


Python Game.from_dict方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import from_dict [as 别名]
 def __init__(self, interactor_factory, renderer):
     """Initialise an instance of DeleteGameHandler.
     :param interactor_factory: The factory object to use for constructing interactors
     :param renderer: The object to use to render output html
     """
     super().__init__(interactor_factory, renderer)
     self.__get_game = lambda args: Game.from_dict({"id": args.get("id", "")})
开发者ID:jeroanan,项目名称:GameCollection,代码行数:9,代码来源:DeleteGameHandler.py

示例2: test_from_dict

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import from_dict [as 别名]
    def test_from_dict(self):
        """Test that mapping a game object from a dictionary is correct."""

        gd = {
            "id": "id",
            "datepurchased": "1/1/1990",
            "genre": "genre",
            "title": "Title",
            "numcopies": 1,
            "numboxed": 2,
            "nummanuals": 3,
            "platform": "Platform",
            "notes": "Notes"
        }

        g = Game.from_dict(gd)

        expected_mappings = {
            "id": g.id,
            "datepurchased": g.date_purchased,
            "genre": g.genre,
            "title": g.title,
            "numcopies": g.num_copies,
            "numboxed": g.num_boxed,
            "nummanuals": g.num_manuals,
            "platform": g.platform,
            "notes": g.notes
        }

        for k, v in expected_mappings.items():
            self.assertEqual(gd[k], v)
开发者ID:jeroanan,项目名称:GameCollection,代码行数:33,代码来源:TestGame.py

示例3: __execute_interactor

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import from_dict [as 别名]
 def __execute_interactor(self, params):
     try:
         interactor = self.interactor_factory.create("UpdateGameInteractor")
         game = Game.from_dict(params)
         interactor.execute(game=game, user_id=self.session.get_value("user_id"))
         return True
     except PersistenceException:
         return False
开发者ID:jeroanan,项目名称:GameCollection,代码行数:10,代码来源:UpdateGameHandler.py

示例4: get_page

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import from_dict [as 别名]
 def get_page(self, params):
     """Handles requests to save a game
     :param params: A dictionary. For details on what keys the dictionary should contain, see
     Game.from_dict()."""
     super().get_page(params)
     
     if not self.validate_params(params, ["title", "platform"]):
         return ""
     interactor = self.interactor_factory.create("AddGameInteractor")
     interactor.execute(game=Game.from_dict(params), user_id=self.session.get_value("user_id"))
开发者ID:jeroanan,项目名称:GameCollection,代码行数:12,代码来源:SaveGameHandler.py

示例5: setUp

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import from_dict [as 别名]
 def setUp(self):
     """setUp function for all unit tests in this class"""
     renderer = Mock(TemplateRenderer)
     interactor_factory = Mock(InteractorFactory)
     self.__interactor = Mock(AddGameInteractor)
     interactor_factory.create = Mock(return_value=self.__interactor)
     self.__target = SaveGameHandler(interactor_factory, renderer)
     session = Mock(Session)
     session.get_value = Mock(return_value="1234")
     self.__target.session = session
     self.__missing_param_returns_empty_string = get_missing_param_assertion(self.__target)
     self.__empty_param_returns_empty_string = get_empty_param_assertion(self.__target)
     self.__required_params = ["title", "platform"]
     self.__get_page = lambda: self.__target.get_page(params=self.__get_args())
     self.__get_game = lambda: Game.from_dict(self.__get_args())
开发者ID:jeroanan,项目名称:GameCollection,代码行数:17,代码来源:TestSaveGameHandler.py

示例6: test_calls_interactor_execute

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import from_dict [as 别名]
 def test_calls_interactor_execute(self):
     """Test that calling UpdateGameHandler.get_page causes UpdateGameInteractor.execute to be called"""
     self.__target.get_page(params=self.__get_params())
     self.__interactor.execute.assert_called_with(game=Game.from_dict(self.__get_params()), user_id="1234")
开发者ID:jeroanan,项目名称:GameCollection,代码行数:6,代码来源:TestUpdateGameHandler.py

示例7: test_calls_interactor_execute

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import from_dict [as 别名]
 def test_calls_interactor_execute(self):
     """Test that calling DeleteGameHandler.get_page causes DeleteGameInteractor.execute to be called"""
     self.__get_page(self.__get_args())
     self.__interactor.execute.assert_called_with(Game.from_dict({"id": "id"}), "1234")
开发者ID:jeroanan,项目名称:GameCollection,代码行数:6,代码来源:TestDeleteGameHandler.py


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