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


Python Game.from_mongo_result方法代码示例

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


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

示例1: test_from_mongo_result_performs_mapping

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import from_mongo_result [as 别名]
    def test_from_mongo_result_performs_mapping(self):
        """Test that mapping a Game object from a MonoDB result is correct"""

        gd = {
            "_id": "id",
            "_Game__genre": "genre",
            "_Game__title": "title",
            "_Game__platform": "platform",
            "_Game__num_copies": 1,
            "_Game__num_boxed": 2,
            "_Game__num_manuals": 3,
            "_Game__notes": "notes",
            "_Game__date_purchased": "2015-05-23",
            "_Game__approximate_date_purchased": True
        }

        g = Game.from_mongo_result(gd)

        expected_mappings = {
            "_id": g.id,
            "_Game__title": g.title,
            "_Game__genre": g.genre,
            "_Game__platform": g.platform,
            "_Game__num_copies": g.num_copies,
            "_Game__num_boxed": g.num_boxed,
            "_Game__num_manuals": g.num_manuals,
            "_Game__notes": g.notes,
            "_Game__date_purchased": g.date_purchased,
            "_Game__approximate_date_purchased": g.approximate_date_purchased
        }
         
        for k,v in expected_mappings.items():
            self.assertEqual(gd[k], v)
开发者ID:jeroanan,项目名称:GameCollection,代码行数:35,代码来源:TestGame.py

示例2: get_game

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import from_mongo_result [as 别名]
 def get_game(self, game_id, user_id):
     """Gets a specific game if it matches the given user.
     :param game_id: A string containing the uuid of the game
     :param user_id: A string containing the uuid of the given user
     :returns: An object of type Game
     """
     try:
         cursor = self.__db.games.find_one({
             "_id": ObjectId(game_id),
             "user_id": str(user_id)
         })
         return Game.from_mongo_result(cursor)
     except InvalidId:
         raise GameNotFoundException
开发者ID:jeroanan,项目名称:GameCollection,代码行数:16,代码来源:MongoPersistence.py

示例3: __map_games_list

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import from_mongo_result [as 别名]
 def __map_games_list(self, result_set):
     return list(map(lambda g: Game.from_mongo_result(g), result_set))
开发者ID:jeroanan,项目名称:GameCollection,代码行数:4,代码来源:MongoPersistence.py


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