Coverage for app/beaverbunch/tests/test_game.py: 100.0%

41 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-08-05 15:01 +0000

1import pytest 

2 

3from app.beaverbunch.src.game.card import Card 

4 

5 

6def test_card_init(): 

7 card = Card(10) 

8 assert card.value == 10 

9 assert str(card) == "PEEK" 

10 

11 with pytest.raises(ValueError): 

12 Card(99) 

13 

14 

15def test_card_equality(): 

16 card1 = Card(5) 

17 card2 = Card(5) 

18 card3 = Card(10) 

19 

20 assert card1 == card2 

21 assert card1 != card3 

22 assert hash(card1) == hash(card2) 

23 assert hash(card1) != hash(card3) 

24 assert card1 != "Not a card" 

25 

26 

27def test_card_comparison(): 

28 card1 = Card(3) 

29 card2 = Card(5) 

30 card3 = Card(2) 

31 

32 assert card1 < card2 

33 assert card2 > card1 

34 assert card3 <= card1 

35 assert card1 >= card3 

36 

37 with pytest.raises(TypeError): 

38 _ = card1 > "not a card" 

39 

40 

41def test_card_repr(): 

42 card = Card(12) 

43 assert repr(card) == "Card(value=12)" 

44 assert str(card) == "DRAW" 

45 

46 card = Card(50) 

47 assert repr(card) == "Card(value=50)" 

48 assert str(card) == "END_GAME" 

49 

50 

51def test_card_invalid_value(): 

52 with pytest.raises(ValueError): 

53 Card(100) 

54 

55 with pytest.raises(ValueError): 

56 Card(-1) 

57 

58 with pytest.raises(ValueError): 

59 Card(11.5) # type: ignore