def test_escaping_sequences_are_ignored_by_file_reader(self):
     content_with_empty_lines = "\tGeorge, Beth, \f  \f Anne" \
                                "\n      " \
                                "\n           " \
                                "\nRick, Anne,    \v Steph        " \
                                "\n     " \
                                "\n\tAnne,     Beth\r" \
                                "\nSteph, George, Rick" \
                                "\n        \t              \t\t\nAlex, \vBob"
     players_txt_file = self.path_to_players_files + 'players.txt'
     utils.clear_the_content_of_the_desired_file(players_txt_file)
     utils.write_some_content_in_the_desired_file(players_txt_file,
                                                  content_with_empty_lines)
     dict_of_players = self.file_reader.turn_the_file_into_dict(
         players_txt_file)
     print(dict_of_players)
     expected_dict = {
         'George': ['Anne', 'Beth'],
         'Rick': ['Anne', 'Steph'],
         'Anne': ['Beth'],
         'Steph': ['George', 'Rick'],
         'Alex': ['Bob']
     }
     comparison_result = utils.compare_two_dicts(dict_of_players,
                                                 expected_dict)
     self.assertTrue(comparison_result)
Esempio n. 2
0
 def test_utils_compare_two_dicts_returns_False_when_lists_are_different(
         self):
     dict1 = {
         'dogs': ['Dachshund', 'Alsacian'],
         'cats': ["Egyptian"],
         'hamsters': ['big', 'small']
     }
     dict2 = {'dogs': ['Dachshund', 'Alsacian']}
     response = utils.compare_two_dicts(dict1, dict2)
     self.assertFalse(response)
Esempio n. 3
0
 def test_utils_strings_can_be_turned_into_an_appropriate_dict_with_players_and_other_players_they_can_see(
         self):
     content = "\t\tPhil, Edward, Liz\nLiz, \tEdward, James, Adam\n\tEdward, Stephen, Phil\nAdam, James"
     expected_dict = {
         "Phil": ["Edward", "Liz"],
         "Liz": ["Edward", "James", "Adam"],
         "Edward": ["Stephen", "Phil"],
         "Adam": ["James"]
     }
     result = utils.turn_string_into_dict_stripped_off_excape_expressions_and_commas(
         content)
     result_of_comparing_two_dicts = utils.compare_two_dicts(
         expected_dict, result)
     self.assertTrue(result_of_comparing_two_dicts)
Esempio n. 4
0
 def test_utils_compare_two_dicts_are_the_same_despite_different_order_of_keys_and_values(
         self):
     dict1 = {
         'dogs': ['Alsacian', 'Dachshund'],
         'hamsters': ['small', 'big'],
         'cats': ["Egyptian"]
     }
     dict2 = {
         'hamsters': ['big', 'small'],
         'cats': ["Egyptian"],
         'dogs': ['Dachshund', 'Alsacian']
     }
     response = utils.compare_two_dicts(dict1, dict2)
     self.assertTrue(response)
 def test_file_reader_turns_content_into_the_dictionary(self):
     players_txt_file = self.path_to_players_files + 'players.txt'
     utils.clear_the_content_of_the_desired_file(players_txt_file)
     utils.write_some_content_in_the_desired_file(players_txt_file,
                                                  self.content_to_write)
     dict_of_players = self.file_reader.turn_the_file_into_dict(
         players_txt_file)
     expected_dict = {
         'George': ['Anne', 'Beth'],
         'Rick': ['Anne', 'Steph'],
         'Anne': ['Beth'],
         'Steph': ['George', 'Rick'],
         'Alex': ['Bob']
     }
     comparison_result = utils.compare_two_dicts(dict_of_players,
                                                 expected_dict)
     self.assertTrue(comparison_result)
 def test_file_reader_ignores_empty_lines_in_a_file(self):
     #ignoring empty lines in a file ensures the clarity of the finally returned dict file
     content_with_empty_lines = "\tGeorge, Beth,    Anne\n      \n           \nRick, Anne, Steph        \n     \n" \
                                "\tAnne, Beth\nSteph, George, Rick\n        \t              \t\t\nAlex, Bob"
     players_txt_file = self.path_to_players_files + 'players.txt'
     utils.clear_the_content_of_the_desired_file(players_txt_file)
     utils.write_some_content_in_the_desired_file(players_txt_file,
                                                  content_with_empty_lines)
     dict_of_players = self.file_reader.turn_the_file_into_dict(
         players_txt_file)
     expected_dict = {
         'George': ['Anne', 'Beth'],
         'Rick': ['Anne', 'Steph'],
         'Anne': ['Beth'],
         'Steph': ['George', 'Rick'],
         'Alex': ['Bob']
     }
     comparison_result = utils.compare_two_dicts(dict_of_players,
                                                 expected_dict)
     self.assertTrue(comparison_result)