def test_handicap_white_loss(db): game_normal = GameFactory( stage='finished', result='B+R', black_user__rating=1700, white_user__rating=1700) game_hc = GameFactory(stage='finished', result='B+R', black_user__rating=1500, white_user__rating=1700) game_hc.board.handicap = 2 game_hc.apply_board_change() svc = RatingService(db) svc.update_ratings(game_normal) svc.update_ratings(game_hc) assert game_normal.white_user.rating == game_hc.white_user.rating
def test_toggle_marked_dead(db, socket): game = GameFactory(stage='counting') svc = GameService(db, socket, game.black_user) svc.user = game.black_user svc.socket.subscribe('game_update/'+str(game.id)) game.board.play(30) game.apply_board_change() svc.execute('toggle_marked_dead', {'game_id': game.id, 'coord': 30}) assert game.board.is_marked_dead(30) assert len(svc.socket.sent_messages) == 1 assert svc.socket.sent_messages[0]['method'] == 'game_update'
def test_resume_from_counting(db, socket): game = GameFactory(stage='counting') game.board.play(PASS) game.board.play(PASS) game.apply_board_change() socket.subscribe('game_update/'+str(game.id)) svc = GameService(db, socket, game.black_user) svc.execute('resume_from_counting', {'game_id': game.id}) assert game.stage == 'playing' assert not game.board.both_passed assert len(socket.sent_messages) == 1 assert socket.sent_messages[0]['method'] == 'game_update'