def test_get_game(self): game = GameFactory() game.active_player = PlayerFactory(id='U1') game.active_player.played_card = Card.query.first() self.api_client.game = game rv = self.auth_get('/game') self.assert_200(rv) rv_data = json.loads(rv.data.decode('utf-8')) self.assertIn('id', rv_data) self.assertEqual(0, rv_data['turn']) self.assertEqual('U1', rv_data['active_player']) self.assertEqual('black card 0', rv_data['active_card'])
def test_leave_game(self): game = GameFactory() self.api_client.game = game player = PlayerFactory(id='U1', played_card_id=11) game.players.append(player) game.active_player = player game.players.append(PlayerFactory(id='U2')) db.session.commit() rv = self.auth_delete('/game/players/U1') self.assert_200(rv) db.session.refresh(game) self.assertEqual(1, game.players.count()) self.assertEqual('U2', game.active_player.id) self.assertEqual(11, game.active_player.played_card_id)