Ejemplo n.º 1
0
    def testStoreScore(self):
        downloaded_score = getScorePDF(self.html)
        create_boije_folder = getOrCreateBoijeFolder(DESTINATION_DIRECTORY, BOIJE_DIRECTORY_NAME)
        create_composer_folder = getOrCreateComposerFolder(create_boije_folder, self.composer)
        downloaded_score = getScorePDF(self.html)
        path_to_score_should_be = os.path.join(create_composer_folder, '%s.pdf'%self.score_name)

        #The output of saveScorePDF will be a tuple (SUCCESS_CODE, PATH_TO_DOWNLOADED_SCORE)
        saving_score_to_folder = saveScorePDF(downloaded_score, self.score_name, create_composer_folder)
        truth_of_score, path_of_score = saving_score_to_folder

        self.assertTrue(truth_of_score)
        self.assertEqual(path_of_score, path_to_score_should_be)
        
        ##now we can test the getScorePath function, this function should return true
        returned_truth_of_get_score_path = getScorePath(self.composer, self.score_name, create_boije_folder)
        self.assertTrue(returned_truth_of_get_score_path)

        returned_false_of_get_score_path = getScorePath(self.composer, self.not_real_score, create_boije_folder)
        self.assertFalse(returned_false_of_get_score_path)
Ejemplo n.º 2
0
    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)