示例#1
0
 def test_exhaust_deck(self, get_player_guess, build_data_object,
                       create_deck, create_game):
     """should fail gracefully if deck is exhausted during gameplay"""
     game = create_game.return_value
     data = build_data_object.return_value
     dealer.run_game(1, self.PLAYERS, self.lock, self.queue)
     nose.assert_equal(game['winner'], None)
     nose.assert_equal(game['rounds'], 4)
     nose.assert_equal(len(data['cards']), 4)
     nose.assert_equal(len(data['previous_guesses']), 3)
     self.queue.put.assert_called_once_with(game)
示例#2
0
 def test_invalid_json(self, get_player_guess, build_data_object,
                       create_deck, create_game):
     """should silently fail when invalid JSON produces ValueError"""
     game = create_game.return_value
     data = build_data_object.return_value
     dealer.run_game(1, self.PLAYERS, self.lock, self.queue)
     nose.assert_equal(game['winner'], None)
     nose.assert_equal(game['rounds'], 1)
     nose.assert_equal(len(data['cards']), 1)
     nose.assert_equal(len(data['previous_guesses']), 0)
     self.queue.put.assert_called_once_with(game)
示例#3
0
 def test_run_game(self, get_player_guess, build_data_object, create_deck,
                   create_game):
     """should run game with given players, taking turns as necessary"""
     game = create_game.return_value
     data = build_data_object.return_value
     dealer.run_game(1, self.PLAYERS, self.lock, self.queue)
     nose.assert_equal(game['winner'], 1)
     nose.assert_equal(game['rounds'], 4)
     nose.assert_equal(len(data['cards']), 4)
     nose.assert_equal(len(data['previous_guesses']), 3)
     self.queue.put.assert_called_once_with(game)