Beispiel #1
0
 def test_choose_game_rule_displays_available_options_and_prompt_text(
         self, mock_builtin_print, mock_builtin_input):
     # test 144
     anthill_card_dict = {
         "top down": [4, 3, 2, 1, 0],
         "bottom up": [0, 1, 2, 3, 4],
         "leave gaps": [4, 2, 0, 3, 1],
         "user choice": None
     }
     prompt_text = "Please enter your choice of anthill card: "
     choose_game_rule(anthill_card_dict, prompt_text)
     expected_print_result_0 = call("\nThe available options are:")
     expected_print_result_1 = call("top down")
     expected_print_result_2 = call("bottom up")
     expected_print_result_3 = call("leave gaps")
     expected_print_result_5 = call(
         "Or enter 'random' to select one of the above options")
     expected_input_result = call(
         "Please enter your choice of anthill card: ")
     self.assertEqual(mock_builtin_print.call_args_list[0],
                      expected_print_result_0)
     self.assertEqual(mock_builtin_print.call_args_list[1],
                      expected_print_result_1)
     self.assertEqual(mock_builtin_print.call_args_list[2],
                      expected_print_result_2)
     self.assertEqual(mock_builtin_print.call_args_list[3],
                      expected_print_result_3)
     self.assertEqual(mock_builtin_print.call_args_list[5],
                      expected_print_result_5)
     self.assertEqual(mock_builtin_input.call_args_list[0],
                      expected_input_result)
Beispiel #2
0
 def test_check_user_can_enter_random_and_one_of_the_other_wine_options_is_selected(
         self, mock_builtin_print, mock_builtin_input):
     # test 230
     chocolate_card_dict = {"turbo": None, "doubler": None}
     prompt_text = "Please enter your choice of chocolate card: "
     expected_results = ["turbo", "doubler"]
     self.assertIn(choose_game_rule(chocolate_card_dict, prompt_text),
                   expected_results)
Beispiel #3
0
 def test_check_user_makes_typo_no_error_redo_choice_select_doubler(
         self, mock_builtin_print, mock_builtin_input):
     # test 229
     chocolate_card_dict = {"turbo": None, "doubler": None}
     prompt_text = "Please enter your choice of chocolate card: "
     expected_result = "doubler"
     self.assertEqual(choose_game_rule(chocolate_card_dict, prompt_text),
                      expected_result)
Beispiel #4
0
 def test_check_game_rule_allows_choice_of_doubler(self, mock_builtin_print,
                                                   mock_builtin_input):
     # test 228
     chocolate_card_dict = {"turbo": None, "doubler": None}
     prompt_text = "Please enter your choice of chocolate card: "
     expected_result = "doubler"
     self.assertEqual(choose_game_rule(chocolate_card_dict, prompt_text),
                      expected_result)
Beispiel #5
0
 def test_check_user_can_enter_random_and_one_of_the_other_wine_options_is_selected(
         self, mock_builtin_print, mock_builtin_input):
     # test 174
     wine_card_dict = {"collector": None, "oenophile": None}
     prompt_text = "Please enter your choice of wine card: "
     expected_results = ["collector", "oenophile"]
     self.assertIn(choose_game_rule(wine_card_dict, prompt_text),
                   expected_results)
Beispiel #6
0
 def test_check_user_makes_typo_no_error_redo_choice_select_oenophile(
         self, mock_builtin_print, mock_builtin_input):
     # test 173
     wine_card_dict = {"collector": None, "oenophile": None}
     prompt_text = "Please enter your choice of wine card: "
     expected_result = "oenophile"
     self.assertEqual(choose_game_rule(wine_card_dict, prompt_text),
                      expected_result)
Beispiel #7
0
 def test_check_game_rule_allows_choice_of_oenophile(
         self, mock_builtin_print, mock_builtin_input):
     # test 172
     wine_card_dict = {"collector": None, "oenophile": None}
     prompt_text = "Please enter your choice of wine card: "
     expected_result = "oenophile"
     self.assertEqual(choose_game_rule(wine_card_dict, prompt_text),
                      expected_result)
Beispiel #8
0
 def test_user_makes_typo_no_error_redo_choice_select_botom_up(
         self, mock_builtin_print, mock_builtin_input):
     # test 140
     anthill_card_dict = {
         "top down": [4, 3, 2, 1, 0],
         "bottom up": [0, 1, 2, 3, 4],
         "leave gaps": [4, 2, 0, 3, 1],
         "user choice": None
     }
     prompt_text = "Please enter your choice of anthill card: "
     expected_result = "bottom up"
     self.assertEqual(choose_game_rule(anthill_card_dict, prompt_text),
                      expected_result)
Beispiel #9
0
 def test_choose_game_rule_allows_choice_of_leave_gaps(
         self, mock_builtin_print, mock_builtin_input):
     # test 139
     anthill_card_dict = {
         "top down": [4, 3, 2, 1, 0],
         "bottom up": [0, 1, 2, 3, 4],
         "leave gaps": [4, 2, 0, 3, 1],
         "user choice": None
     }
     prompt_text = "Please enter your choice of anthill card: "
     expected_result = "leave gaps"
     self.assertEqual(choose_game_rule(anthill_card_dict, prompt_text),
                      expected_result)
Beispiel #10
0
 def test_user_can_enter_random_and_one_of_the_other_anthill_options_is_selected(
         self, mock_builtin_print, mock_builtin_input):
     # test 143
     anthill_card_dict = {
         "top down": [4, 3, 2, 1, 0],
         "bottom up": [0, 1, 2, 3, 4],
         "leave gaps": [4, 2, 0, 3, 1],
         "user choice": None
     }
     prompt_text = "Please enter your choice of anthill card: "
     expected_results = [
         "top down", "bottom up", "leave gaps", "user choice"
     ]
     self.assertIn(choose_game_rule(anthill_card_dict, prompt_text),
                   expected_results)
Beispiel #11
0
 def test_choose_game_rule_also_displays_user_choice_option_and_allows_it_to_be_selected(
         self, mock_builtin_print, mock_builtin_input):
     # test 151
     anthill_card_dict = {
         "top down": [4, 3, 2, 1, 0],
         "bottom up": [0, 1, 2, 3, 4],
         "leave gaps": [4, 2, 0, 3, 1],
         "user choice": None
     }
     prompt_text = "Please enter your choice of anthill card: "
     expected_print_result_3 = call("leave gaps")
     expected_print_result_4 = call("user choice")
     expected_print_result_5 = call(
         "Or enter 'random' to select one of the above options")
     expected_returned_choice = "user choice"
     actual_returned_choice = choose_game_rule(anthill_card_dict,
                                               prompt_text)
     self.assertEqual(mock_builtin_print.call_args_list[3],
                      expected_print_result_3)
     self.assertEqual(mock_builtin_print.call_args_list[4],
                      expected_print_result_4)
     self.assertEqual(mock_builtin_print.call_args_list[5],
                      expected_print_result_5)
     self.assertEqual(actual_returned_choice, expected_returned_choice)