本文整理汇总了Python中models.Game.update_status方法的典型用法代码示例。如果您正苦于以下问题:Python Game.update_status方法的具体用法?Python Game.update_status怎么用?Python Game.update_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Game
的用法示例。
在下文中一共展示了Game.update_status方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_status
# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import update_status [as 别名]
def test_update_status(self):
game = Game()
game.register_player()
json_string = '{"id": "asc123hjk", "distance": 20, "light_color": "green", "player_1": {"name": "Player 1", "location": 4, "in_motion": "true"}, "player_2": {"name": "Player 2", "location": 6, "in_motion": "true"}}'
self.assertEqual(0, game.player_1.location)
self.assertEqual(0, game.player_2.location)
self.assertIsNone(game.light_color)
self.assertEqual(20, game.distance)
self.assertFalse(game.player_1.in_motion)
self.assertFalse(game.player_2.in_motion)
game.update_status(json_string)
self.assertEqual(4, game.player_1.location)
self.assertEqual(6, game.player_2.location)
self.assertEqual('green', game.light_color)
self.assertEqual(20, game.distance)
self.assertTrue(game.player_1.in_motion)
self.assertTrue(game.player_2.in_motion)