def testMakeScoreNameComputerReady(self): score_1 = 'Op. 24. Andante. Se: Gitarristische Vereinigung ... XVI. Jahrg. Nr 3. 1915' score_2 = 'Op. 22. Trois Sonates ...' score_3 = 'Oeuvres pour Guitare. No 1. Ètude.' score_4 = '”ERATO” Auswahl beliebter Gesänge ... No. 18. Santa Lucia! ...' test_string = '"órgão"' converted_score_1 = convertScoreName(score_1) converted_score_2 = convertScoreName(score_2) converted_score_3 = convertScoreName(score_3) converted_score_4 = convertScoreName(score_4) converted_score_5 = convertScoreName(test_string) self.assertEqual('Op_24_Andante_Se_Gitarristische_Vereinigung_XVI_Jahrg_Nr_3_1915', converted_score_1) self.assertEqual('Op_22_Trois_Sonates', converted_score_2) self.assertEqual('Oeuvres_pour_Guitare_No_1_Etude', converted_score_3) self.assertEqual('ERATO_Auswahl_beliebter_Gesange_No_18_Santa_Lucia', converted_score_4) self.assertEqual('orgao', converted_score_5)
def testScoreDownloader(self): index_to_check = 'c' boije_directory, json_file_path = boijeCollectionInit(DESTINATION_DIRECTORY, BOIJE_DIRECTORY_NAME) link_to_check = boijeLink(index_to_check) convert_index_to_dictionary = convertIndexToDictionary(getIndexSoup(link_to_check)) copy_of_dict = copy.deepcopy(convert_index_to_dictionary) ##lets check some composers composer_1 = 'Carcassi_M' composer_2 = 'anon' composer_3 = 'Cottin_A' carcassi_score_1 = convertScoreName('Op. 1. 3 Sonates.') carcassi_score_2 = convertScoreName('Op. 15. Tra la la. Air Varié …') carcassi_score_3 = convertScoreName('Op. 2. Trois Rondo Pour Guitare ou Lyre ...') anon_score_1 = convertScoreName('CHITARRISTA Moderna Pezzi Favoriti ...') anon_score_2 = convertScoreName('CIEBRA’s Hand-book for the Guitar ...') cottin_score_1 = convertScoreName('Ballade circassienne ...') cottin_score_2 = convertScoreName('Habanera.') ##### check paths, let's just make functions that check for paths path_to_carcassi_folder = os.path.join(self.directory_path, composer_1) path_to_anon_folder = os.path.join(self.directory_path, composer_2) path_to_cottin_folder = os.path.join(self.directory_path, composer_3) returned_dictionary = scoreDownloader(copy_of_dict, boije_directory, json_file_path) #throughout the download process, the dictionary returned by downloaded should be different #There should be some truth values self.assertNotEqual(convert_index_to_dictionary, returned_dictionary) self.assertTrue(returned_dictionary.get(composer_1).get(carcassi_score_1)[2]) self.assertTrue(returned_dictionary.get(composer_2).get(anon_score_1)[2]) ## ## Now the file paths should exist. carcassi_score_1_exists = getScorePath(composer_1, carcassi_score_1, boije_directory) carcassi_score_2_exists = getScorePath(composer_1, carcassi_score_2, boije_directory) carcassi_score_3_exists = getScorePath(composer_1, carcassi_score_3, boije_directory) anon_score_1_exists = getScorePath(composer_2, anon_score_1, boije_directory) anon_score_2_exists = getScorePath(composer_2, anon_score_2, boije_directory) cottin_score_1_exists = getScorePath(composer_3, cottin_score_1, boije_directory) cottin_score_2_exists = getScorePath(composer_3, cottin_score_2, boije_directory) self.assertTrue(carcassi_score_1_exists) self.assertTrue(carcassi_score_2_exists) self.assertTrue(carcassi_score_3_exists) self.assertTrue(anon_score_1_exists) self.assertTrue(anon_score_2_exists) self.assertTrue(cottin_score_1_exists) self.assertTrue(cottin_score_2_exists)