2022-11-18 19:30:19 +00:00
|
|
|
import pytest
|
|
|
|
from pydantic import ValidationError
|
|
|
|
|
2022-11-18 20:27:21 +00:00
|
|
|
from poker.constants import Value
|
2022-11-18 19:30:19 +00:00
|
|
|
from poker.models import Card, Hand
|
2022-11-18 20:27:21 +00:00
|
|
|
from tests.conftest import Factory
|
2022-11-18 19:30:19 +00:00
|
|
|
|
|
|
|
|
2022-11-18 20:27:21 +00:00
|
|
|
def test_hand_should_contain_unique_cards(card_factory: Factory[Card]) -> None:
|
|
|
|
cards = [
|
|
|
|
Value.ACE,
|
|
|
|
Value.TWO,
|
|
|
|
Value.THREE,
|
|
|
|
Value.FOUR,
|
|
|
|
]
|
2022-11-18 19:30:19 +00:00
|
|
|
with pytest.raises(ValidationError):
|
|
|
|
_ = Hand(
|
2022-11-18 20:27:21 +00:00
|
|
|
cards=tuple(card_factory(value=value) for value in cards + [Value.FOUR])
|
2022-11-18 19:30:19 +00:00
|
|
|
)
|
|
|
|
|
2022-11-18 20:27:21 +00:00
|
|
|
_ = Hand(cards=tuple(card_factory(value=value) for value in cards + [Value.FIVE]))
|