You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tests.txt 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. >>> import quartett as q
  2. >>> import clean_input as c
  3. >>> players_with_cards = [{'player': 'player0', 'cards_on_hand': [{'id': '1', 'number':
  4. ... '0', 'letter': 'b'}, {'id': '30', 'number': '3', 'letter': 'g'}, {'id': '7', 'number': '0',
  5. ... 'letter': 'h'}, {'id': '9', 'number': '1', 'letter': 'b'}, {'id': '5', 'number': '0',
  6. ... 'letter': 'f'}, {'id': '24', 'number': '3', 'letter': 'a'}, {'id': '13', 'number': '1',
  7. ... 'letter': 'f'}, {'id': '2', 'number': '0', 'letter': 'c'}, {'id': '6', 'number': '0',
  8. ... 'letter': 'g'}, {'id': '16', 'number': '2', 'letter': 'a'}], 'quartet': 0},
  9. ... {'player': 'player1', 'cards_on_hand': [{'id': '27', 'number': '3', 'letter': 'd'},
  10. ... {'id': '12', 'number': '1', 'letter': 'e'}, {'id': '15', 'number': '1', 'letter': 'h'},
  11. ... {'id': '17', 'number': '2', 'letter': 'b'}, {'id': '8', 'number': '1', 'letter': 'a'},
  12. ... {'id': '26', 'number': '3', 'letter': 'c'}, {'id': '31', 'number': '3', 'letter': 'h'},
  13. ... {'id': '21', 'number': '2', 'letter': 'f'}, {'id': '29', 'number': '3', 'letter': 'f'},
  14. ... {'id': '11', 'number': '1', 'letter': 'd'}, {'id': '20', 'number': '2', 'letter': 'e'}],
  15. ... 'quartet': 1},
  16. ... {'player': 'player2', 'cards_on_hand': [{'id': '23', 'number': '2', 'letter': 'h'},
  17. ... {'id': '19', 'number': '2', 'letter': 'd'}, {'id': '18', 'number': '2', 'letter': 'c'},
  18. ... {'id': '0', 'number': '0', 'letter': 'a'}, {'id': '22', 'number': '2', 'letter': 'g'},
  19. ... {'id': '3', 'number': '0', 'letter': 'd'}, {'id': '14', 'number': '1', 'letter': 'g'},
  20. ... {'id': '25', 'number': '3', 'letter': 'b'}, {'id': '4', 'number': '0', 'letter': 'e'},
  21. ... {'id': '28', 'number': '3', 'letter': 'e'}], 'quartet': 2}]
  22. 1. pretty_print_deck(players_with_cards, player)
  23. Positivtests:
  24. >>> q.pretty_print_deck(players_with_cards, 0)
  25. Dein Deck: ['0b', '3g', '0h', '1b', '0f', '3a', '1f', '0c', '0g', '2a']
  26. >>> q.pretty_print_deck(players_with_cards, 1) is None
  27. True
  28. >>> q.pretty_print_deck(players_with_cards, 2) is None
  29. True
  30. Negativtests:
  31. >>> q.pretty_print_deck("player", 0)
  32. Traceback (most recent call last):
  33. ...
  34. TypeError: string indices must be integers
  35. >>> q.pretty_print_deck([0], 1)
  36. Traceback (most recent call last):
  37. ...
  38. IndexError: list index out of range
  39. ---
  40. 2. steal(active, chosen_player, players_with_cards, player_request)
  41. Positivtests:
  42. >>> active = 1
  43. >>> chosen_player = 2
  44. >>> player_request = {'id': '3', 'number': '0', 'letter': 'd'}
  45. >>> q.steal(active, chosen_player, players_with_cards, player_request)
  46. player2 hat die Karte, die player1 haben möchte und sie wandert in sein Deck.
  47. >>> active = 0
  48. >>> chosen_player = 1
  49. >>> player_request = {'id': '27', 'number': '3', 'letter': 'd'}
  50. >>> q.steal(active, chosen_player, players_with_cards, player_request)
  51. player1 hat die Karte, die du haben möchtest und sie wandert in dein Deck.
  52. >>> active = 2
  53. >>> chosen_player = 1
  54. >>> player_request = {'id': '12', 'number': '1', 'letter': 'e'}
  55. >>> q.steal(active, chosen_player, players_with_cards, player_request)
  56. player1 hat die Karte, die player2 haben möchte und sie wandert in sein Deck.
  57. Negativtests:
  58. >>> active = 2
  59. >>> chosen_player = 1
  60. >>> player_request = {'id': '12', 'number': '1', 'letter': 'k'}
  61. >>> q.steal(active, chosen_player, players_with_cards, player_request)
  62. Traceback (most recent call last):
  63. ...
  64. ValueError: {'id': '12', 'number': '1', 'letter': 'k'} is not in list
  65. >>> active = 2
  66. >>> chosen_player = 1
  67. >>> player_request = {}
  68. >>> q.steal(active, chosen_player, players_with_cards, player_request)
  69. Traceback (most recent call last):
  70. ...
  71. ValueError: {} is not in list
  72. ---
  73. 3. drop_cards_help(p, all_quartets)
  74. Positivtests:
  75. >>> p = players_with_cards[0]
  76. >>> for i in range(4):
  77. ... p["cards_on_hand"][i]["letter"] = "b"
  78. >>> all_quartets = []
  79. >>> q.drop_cards_help(p, all_quartets)
  80. Du legst das b-Quartett ab...
  81. >>> p = players_with_cards[1]
  82. >>> for i in range(4):
  83. ... p["cards_on_hand"][i]["letter"] = "c"
  84. >>> q.drop_cards_help(p, all_quartets)
  85. player1 legt das c-Quartett ab...
  86. >>> p = players_with_cards[2]
  87. >>> for i in range(4):
  88. ... p["cards_on_hand"][i]["letter"] = "d"
  89. >>> q.drop_cards_help(p, all_quartets)
  90. player2 legt das d-Quartett ab...
  91. Negativtests:
  92. >>> p = players_with_cards[0]
  93. >>> q.drop_cards_help(p, all_quartets) is None
  94. True
  95. >>> p = players_with_cards[1]
  96. >>> q.drop_cards_help(p, all_quartets) is None
  97. True
  98. ---
  99. # remove end_screen() from the_winner_is to test it
  100. 4. the_winner_is(players_with_cards, players)
  101. Positivtests:
  102. >>> players_with_cards = [{'player': 'player0', 'cards_on_hand': [{'id': '1', 'number':
  103. ... '0', 'letter': 'b'}, {'id': '30', 'number': '3', 'letter': 'g'}, {'id': '7', 'number': '0',
  104. ... 'letter': 'h'}, {'id': '9', 'number': '1', 'letter': 'b'}, {'id': '5', 'number': '0',
  105. ... 'letter': 'f'}, {'id': '24', 'number': '3', 'letter': 'a'}, {'id': '13', 'number': '1',
  106. ... 'letter': 'f'}, {'id': '2', 'number': '0', 'letter': 'c'}, {'id': '6', 'number': '0',
  107. ... 'letter': 'g'}, {'id': '16', 'number': '2', 'letter': 'a'}], 'quartet': 0},
  108. ... {'player': 'player1', 'cards_on_hand': [{'id': '27', 'number': '3', 'letter': 'd'},
  109. ... {'id': '12', 'number': '1', 'letter': 'e'}, {'id': '15', 'number': '1', 'letter': 'h'},
  110. ... {'id': '17', 'number': '2', 'letter': 'b'}, {'id': '8', 'number': '1', 'letter': 'a'},
  111. ... {'id': '26', 'number': '3', 'letter': 'c'}, {'id': '31', 'number': '3', 'letter': 'h'},
  112. ... {'id': '21', 'number': '2', 'letter': 'f'}, {'id': '29', 'number': '3', 'letter': 'f'},
  113. ... {'id': '11', 'number': '1', 'letter': 'd'}, {'id': '20', 'number': '2', 'letter': 'e'}],
  114. ... 'quartet': 1},
  115. ... {'player': 'player2', 'cards_on_hand': [{'id': '23', 'number': '2', 'letter': 'h'},
  116. ... {'id': '19', 'number': '2', 'letter': 'd'}, {'id': '18', 'number': '2', 'letter': 'c'},
  117. ... {'id': '0', 'number': '0', 'letter': 'a'}, {'id': '22', 'number': '2', 'letter': 'g'},
  118. ... {'id': '3', 'number': '0', 'letter': 'd'}, {'id': '14', 'number': '1', 'letter': 'g'},
  119. ... {'id': '25', 'number': '3', 'letter': 'b'}, {'id': '4', 'number': '0', 'letter': 'e'},
  120. ... {'id': '28', 'number': '3', 'letter': 'e'}], 'quartet': 2}]
  121. >>> players = ["player0", "player1", "player2"]
  122. >>> q.the_winner_is(players_with_cards, players)
  123. <BLANKLINE>
  124. player2 hat das Spiel gewonnen!
  125. >>> players_with_cards[1]["quartet"] = 2
  126. >>> q.the_winner_is(players_with_cards, players)
  127. <BLANKLINE>
  128. player1 hat das Spiel gewonnen!
  129. player2 hat das Spiel gewonnen!
  130. >>> players_with_cards[0]["quartet"] = 2
  131. >>> q.the_winner_is(players_with_cards, players)
  132. <BLANKLINE>
  133. Du hast das Spiel gewonnen!
  134. player1 hat das Spiel gewonnen!
  135. player2 hat das Spiel gewonnen!
  136. Negativtests:
  137. >>> q.the_winner_is(players_with_cards[0], players)
  138. Traceback (most recent call last):
  139. ...
  140. KeyError: 0
  141. >>> q.the_winner_is(players_with_cards)
  142. Traceback (most recent call last):
  143. ...
  144. TypeError: the_winner_is() missing 1 required positional argument: 'players'