From 6be02c447dd19a3a103c9735600604f5be58de75 Mon Sep 17 00:00:00 2001 From: Paul Harrison Date: Fri, 18 Nov 2022 19:30:19 +0000 Subject: feat: Ensure hand comprises unique cards --- tests/test_models.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/test_models.py (limited to 'tests/test_models.py') 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), + ) + ) -- cgit v1.2.3