예제 #1
0
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
예제 #2
0
def test_active_games_demo_not_in_room(db):
    DemoGameFactory(demo_owner__is_online=False)
    assert Game.active_games(db).count() == 0
예제 #3
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
예제 #4
0
 def _connection_data_active_games(self):
     return {
         'active_games':
         [g.to_frontend() for g in Game.active_games(self.db)]
     }