Esempio n. 1
0
	def test_to_minimal_string(self):
		test_cases = {
			'ACE': 'A', 'TWO': '2', 'THREE': '3', 'FOUR': '4', 'FIVE': '5', 'SIX': '6', 'SEVEN': '7', 'EIGHT': '8',
			'NINE': '9', 'TEN': 'T', 'JACK': 'J', 'QUEEN': 'Q', 'KING': 'K'
		}

		for input, output in test_cases.items():
			card_rank = CardRank(input)
			assert card_rank.to_minimal_string() == output
Esempio n. 2
0
	def test_to_string(self):
		test_cases = {
			'ACE': 'Ace', 'TWO': 'Two', 'THREE': 'Three', 'FOUR': 'Four', 'FIVE': 'Five', 'SIX': 'Six', 'SEVEN': 'Seven',
			'EIGHT': 'Eight', 'NINE': 'Nine', 'TEN': 'Ten', 'JACK': 'Jack', 'QUEEN': 'Queen', 'KING': 'King'
		}

		for input, output in test_cases.items():
			card_rank = CardRank(input)
			assert card_rank.to_string() == output
Esempio n. 3
0
	def test_normal_inputs(self):
		card = Card('HEARTS', 'FOUR')
		assert card.suit == CardSuit('HEARTS')
		assert card.rank == CardRank('FOUR')

		card = Card('Spades', 'ace')
		assert card.suit == CardSuit('SPADES')
		assert card.rank == CardRank('ACE')

		card = Card('JOKER')
		assert card.is_joker()
		assert card.suit == CardSuit('JOKER')
		assert not hasattr(card, 'rank')

		card = Card('JOKER', None)
		assert card.is_joker()
		assert card.suit == CardSuit('JOKER')
		assert not hasattr(card, 'rank')
Esempio n. 4
0
	def test_eq_ne(self):
		positive_test_cases = [
			[ CardRank('SEVEN'), CardRank('SEVEN') ],
			[ CardRank('KING'), CardRank('king') ],
			[ CardRank('JACK'), 'JACK' ],
			[ CardRank('ACE'), 'ace' ]
		]

		negative_test_cases = [
			[ CardRank('SEVEN'), 7 ],
			[ CardRank('SEVEN'), '' ],
			[ CardRank('SEVEN'), '7' ],
			[ CardRank('SEVEN'), True ],
			[ CardRank('SEVEN'), False ],
			[ CardRank('SEVEN'), None ],
			[ CardRank('SEVEN'), CardRank('SIX') ],
			[ CardRank('SEVEN'), CardRank('QUEEN') ]
		]

		for test_case in positive_test_cases:
			left, right = test_case[0], test_case[1]
			assert left == right
			assert right == left
			assert not left != right
			assert not right != left

		for test_case in negative_test_cases:
			left, right = test_case[0], test_case[1]
			assert not left == right
			assert not right == left
			assert left != right
			assert right != left
Esempio n. 5
0
	def test_rank_normal_inputs(self):
		ranks = ['ACE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE', 'TEN', 'JACK', 'QUEEN', 'KING']

		for rank in ranks:
			card_rank = CardRank(rank)
			assert card_rank.rank == rank.upper()
Esempio n. 6
0
	def test_repr(self):
		ranks = ['ACE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE', 'TEN', 'JACK', 'QUEEN', 'KING']

		for rank in ranks:
			assert repr(CardRank(rank)) == f'CardRank({rank})'
Esempio n. 7
0
	def test_rank_invalid_inputs(self):
		inputs = ['ACE ', '', 'A', '4', 4, True, False, None]

		for input in inputs:
			with pytest.raises(ValueError):
				card_rank = CardRank(input)
Esempio n. 8
0
	def test_rank_alternate_inputs(self):
		ranks = ['Ace', 'two', 'ThReE', 'fOuR', 'fIVE']

		for rank in ranks:
			card_rank = CardRank(rank)
			assert card_rank.rank == rank.upper()