def test_player_playable(self): with self.assertRaises(NotImplementedError): a2.Player("Test Player").is_playable() self.assertIs( a2.HumanPlayer("Test Player").is_playable(), True, "HumanPlayer.is_playable should return True") self.assertIs( a2.ComputerPlayer("Test Player").is_playable(), False, "ComputerPlayer.is_playable should return False")
def test_player_has_won(self): player = a2.Player("Test Player") self.assertIs(player.has_won(), True) player.get_deck().add_card(a2.Card(9, a2_support.CardColour.blue)) player.get_deck().add_card(a2.Card(8, a2_support.CardColour.red)) player.get_deck().add_card(a2.Card(7, a2_support.CardColour.black)) self.assertIs(player.has_won(), False, "Player.has_won should return False if the Player has cards")
def test_player_pick_card(self): deck = a2.Deck() deck.add_cards([ a2.Card(1, a2_support.CardColour.blue), a2.Card(3, a2_support.CardColour.red), a2.Card(2, a2_support.CardColour.green), a2.Card(4, a2_support.CardColour.yellow), a2.Card(6, a2_support.CardColour.yellow), a2.Card(10, a2_support.CardColour.blue) ]) with self.assertRaises(NotImplementedError): a2.Player("Test Player").pick_card(deck) player = a2.HumanPlayer("Test Player") player.get_deck().add_cards(deck.get_cards().copy()) self.assertIsNone(player.pick_card(deck), 'HumanPlayer.pick_card should return None')
def test_player_constructor(self): player = a2.Player("Test Player") self.assertEqual(player.get_name(), "Test Player") self.assertListEqual(player.get_deck().get_cards(), [], "Player should have no cards initially")