def __get_expected(self): return { 'respond_north_and_name': 'player north {}'.format(State.NAME), 'respond_south_and_name': 'player south {}'.format(State.NAME), 'read_and_set_colors': ('a', 'b', 'c', 'd', 'e', 'f'), 'read_and_set_player_hand': [Card('color1', number).value for number in range(1, 8)], 'read_and_set_flag_claim_status': ['unclaimed'] * 9, 'read_and_set_flag_messages_no_cards': [], 'read_and_set_flag_messages_one_card': [Card('color1', 1).value], 'read_and_set_flag_messages_three_cards': [Card('color1', 1).value, Card('color2', 2).value, Card('color3', 3).value], 'read_and_set_opponent_last_play': {'flag': 1, 'card': Card('color1', 1).value} }
def __stage_mock_state(self): self.mock_state.seat = 'north' self.mock_state.colors = ['color{}'.format(num) for num in range(1, 7)] self.mock_state.hand = [ Card('color1', number).value for number in range(1, 8) ] self.mock_state.flags = Flags()
def __list_of_three_cards(self): return [Card('puse', num).value for num in range(1, 4)]
def test_random_strategy_returns_random_card(self): hand = [Card().card_to_text(card) for card in self.mock_state.hand] parsed = self.__update_and_parse_reply() self.assertEqual('play', parsed[0]) self.assertIn(int(parsed[1]), self.flags) self.assertIn(parsed[2], hand)
def __make_card_list(self, parsed): return [Card().text_to_card(card) for card in parsed[4:]]
def __parse_hand(self, message): self.state.hand = [ Card().text_to_card(card) for card in message.split()[3:] ] return False
def __make_last_play_dict(self, flag, card): return {'flag': int(flag), 'card': Card().text_to_card(card)}
def setUp(self): self.flags = Flags() self.flag_set = [[] for _ in range(Flags.NUM_FLAGS)] self.card_list = [Card('puse', 1).value]
def test_text_to_card(self): self.assertEqual(Card().value, Card().text_to_card()) self.assertEqual(Card('puse', 1).value, Card().text_to_card('puse,1'))
def test_card_to_text(self): self.assertEqual('puce,1', Card().card_to_text(['puce', 1]))
def test_new_card_given_paramaters(self): self.assertEqual(['puce', 1], Card('puce', 1).value)
def test_new_card_with_no_parameters(self): self.assertEqual(['empty', 0], Card().value)
def __random_reply_text(self, flags, cards): return 'play {} {}'.format( self.__get_first(flags), Card().card_to_text(self.__get_first(cards)))