Beispiel #1
0
    def test_print_results__one_person_high_hand(self, mock_print: MagicMock):
        person = HumanPlayer("Matthew")
        person.print_player = MagicMock()
        person.cards = [Card(10, "Test"), Card(10, "Test"), Card(10, "Test")]
        print_game_results([person])

        person.print_player.assert_called_once()
Beispiel #2
0
    def test_print_results__one_person__is_winner(self, mock_print: MagicMock):
        person = HumanPlayer("Matthew")
        person.print_player = MagicMock()
        person.cards = []

        print_game_results([person])

        mock_print.assert_called_once_with("Winner: Matthew")
Beispiel #3
0
    def test_print_results__people_single_winner(self, mock_print: MagicMock):
        matt = HumanPlayer("Matthew")
        matt.print_player = MagicMock()
        matt.cards = [Card(2, "Test")]

        sam = HumanPlayer("Sam")
        sam.print_player = MagicMock()
        sam.cards = [Card(10, "Test")]

        hannah = HumanPlayer("Hannah")
        hannah.print_player = MagicMock()
        hannah.cards = [Card(5, "Test")]

        players = [matt, sam, hannah]
        print_game_results(players)

        mock_print.assert_called_once_with("Winner: Sam")
Beispiel #4
0
    def test_print_results__people_print_person_called_once(
            self, mock_print: MagicMock):
        matt = HumanPlayer("Matthew")
        matt.print_player = MagicMock()
        matt.cards = [Card(2, "Test")]

        sam = HumanPlayer("Sam")
        sam.print_player = MagicMock()
        sam.cards = [Card(10, "Test")]

        hannah = HumanPlayer("Hannah")
        hannah.print_player = MagicMock()
        hannah.cards = [Card(5, "Test")]

        players = [matt, sam, hannah]
        print_game_results(players)
        for player in players:
            with self.subTest(player=player.name):
                player.print_player.assert_called_once()
Beispiel #5
0
    def test_print_results__people_joint_winner(self, mock_print: MagicMock):
        matt = HumanPlayer("Matthew")
        matt.print_player = MagicMock()
        matt.cards = [Card(2, "Test")]

        sam = HumanPlayer("Sam")
        sam.print_player = MagicMock()
        sam.cards = [Card(10, "Test")]

        hannah = HumanPlayer("Hannah")
        hannah.print_player = MagicMock()
        hannah.cards = [Card(10, "Test")]

        players = [matt, sam, hannah]
        print_game_results(players)

        mock_print.assert_any_call("Winner: Sam")
        mock_print.assert_any_call("Winner: Hannah")
        self.assertRaises(
            AssertionError,
            lambda: mock_print.assert_any_call("Winner: Matthew"))
Beispiel #6
0
    def test_print_results__one_person_empty_hand(self, mock_print: MagicMock):
        person = HumanPlayer("Matthew")
        person.print_player = MagicMock()
        print_game_results([person])

        person.print_player.assert_called_once()