本文整理汇总了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)
示例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
示例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))