def test_init_get_hand(self): game = HeartsGame() try: game.get_hand(0) self.fail() except e.RoundNotInProgressError: pass # test succeeded
def test_start_game_preround(self): """ When the game is started, it should go into the first pre-round, passing left. """ game = HeartsGame(deal_func=lambda: example_hands) observer = Mock() game.add_observer(observer) game.start() self.assertEqual("passing", game.get_state()) self.assertEqual("left", game.get_pass_direction()) self.assertEqual(example_hands[0], game.get_hand(0))
def test_finish_passing(self): """ Tests that the state transitions properly into playing when passing is finished. """ game = HeartsGame(deal_func=lambda: example_hands) observer = Mock() game.add_observer(observer) game.start() for i in range(4): game.pass_cards(i, example_hands[i][:3]) self.assertEqual("playing", game.get_state()) self.assertEqual(1, game.get_current_player()) new_hand = example_hands[0][:3] + example_hands[1][3:] self.assertEqual(set(new_hand), set(game.get_hand(1)))