def test_active_games(db): g1 = GameFactory(stage='playing') g2 = GameFactory(stage='playing') RoomUserFactory(room=g1.room, user=g1.black_user) RoomUserFactory(room=g1.room, user=g1.white_user) RoomUserFactory(room=g2.room, user=g2.black_user) RoomUserFactory(room=g2.room, user=g2.white_user) assert Game.active_games(db).count() == 2
def test_active_games_demo_not_in_room(db): DemoGameFactory(demo_owner__is_online=False) assert Game.active_games(db).count() == 0
def test_active_games_demo_offline(db): demo = DemoGameFactory(demo_owner__is_online=False) RoomUserFactory(room=demo.room, user=demo.demo_owner) assert Game.active_games(db).count() == 0
def _connection_data_active_games(self): return { 'active_games': [g.to_frontend() for g in Game.active_games(self.db)] }