diff options
author | Paul Harrison <paul@harrison.sh> | 2022-11-18 19:30:19 +0000 |
---|---|---|
committer | Paul Harrison <paul@harrison.sh> | 2022-12-15 16:02:14 +0000 |
commit | 6be02c447dd19a3a103c9735600604f5be58de75 (patch) | |
tree | 9f046f3c702165285fb0a25b7ec8c0c19766cc51 /tests | |
parent | c337984965c38b87319befbe97547c0420371aef (diff) |
feat: Ensure hand comprises unique cards
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_models.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_models.py b/tests/test_models.py new file mode 100644 index 0000000..37e9c03 --- /dev/null +++ b/tests/test_models.py @@ -0,0 +1,28 @@ +import pytest +from pydantic import ValidationError + +from poker.constants import Suit, Value +from poker.models import Card, Hand + + +def test_hand_should_contain_unique_cards() -> None: + with pytest.raises(ValidationError): + _ = Hand( + cards=( + Card(suit=Suit.CLUBS, value=Value.ACE), + Card(suit=Suit.CLUBS, value=Value.TWO), + Card(suit=Suit.CLUBS, value=Value.THREE), + Card(suit=Suit.CLUBS, value=Value.FOUR), + Card(suit=Suit.CLUBS, value=Value.FOUR), + ) + ) + + _ = Hand( + cards=( + Card(suit=Suit.CLUBS, value=Value.ACE), + Card(suit=Suit.CLUBS, value=Value.TWO), + Card(suit=Suit.CLUBS, value=Value.THREE), + Card(suit=Suit.CLUBS, value=Value.FOUR), + Card(suit=Suit.CLUBS, value=Value.FIVE), + ) + ) |