def test_update_no_active_player_makes_next_active(self):
# Setup, add some players to waiting list.
laser_players = players.Players(1)
laser_players.add_player('192.168.0.1')
# Check none are yet active.
self.assertEqual(None, laser_players.active_player())
# Setup, create mock callbacks that will remember how they were called.
start_active = unittest.mock.Mock()
end_active = unittest.mock.Mock()
# Call update with 1 second of time elapsed.
laser_players.update(0.5, start_active, end_active)
# Check start active was called with the first in line IP, and that the
# currently active player is the first one added (with 1 second of playtime
# left).
start_active.assert_called_once_with('192.168.0.1')
end_active.assert_not_called()
self.assertEqual(('192.168.0.1', 1), laser_players.active_player())
评论列表
文章目录