Exemplo n.º 1
0
    def testGetScoreByBoijeNumber(self):
        score_1 = "Boije 1.pdf"
        score_2 = "Boije 2.pdf"
        boije_directory, json_file_path = boijeCollectionInit(
            DESTINATION_DIRECTORY, BOIJE_DIRECTORY_NAME)
        scores_dictionary = dictionaryInit(json_file_path)

        time.sleep(5) ##sleep
        score_1_number = getBoijeNumber(score_1)
        score_2_number = getBoijeNumber(score_2)
    
        # make sure a duplicate folder is not within the directory
        self.assertFalse(os.path.exists(
            "./boije_test_directory/boije_test_directory"))

        self.assertEqual("1", score_1_number)
        self.assertEqual("2", score_2_number)

        composer_1, score_1_name = getScoreNameWithBoijeNumber(scores_dictionary, score_1_number)
        composer_2, score_2_name = getScoreNameWithBoijeNumber(scores_dictionary, score_2_number)

        self.assertEqual(composer_1, "Aguado_D")
        self.assertEqual(score_1_name, "Op_1_Douze_valses")
        self.assertEqual(composer_2, "Aguado_D")
        self.assertEqual(score_2_name, "Op_2_Trois_rondos_brillants")
Exemplo n.º 2
0
    def setUp(self):
        super(RenamerUtilityTests, self).setUp()
        score_1_path = "./Boije 1.pdf"
        score_2_path = "./Boije 2.pdf"
        json_file_path = os.path.join(os.getcwd(), JSON_FILE_NAME)
        if not os.path.exists(score_1_path):
            # Download this score
            score_1_url = "pdf/Boije%201.pdf"
            score_1 = getScorePDF(score_1_url)
            saveScorePDF(score_1, "Boije 1", ".")

        if not os.path.exists("./Boije 2.pdf"):
            #Download this score
            score_2_url = "pdf/Boije%202.pdf"
            score_2 = getScorePDF(score_2_url) 
            saveScorePDF(score_2, "Boije 2", ".")
        if (not os.path.exists(json_file_path) or 
                not os.path.getsize(json_file_path)):
            json_file_path = createJsonFile(JSON_FILE_NAME, os.getcwd())
            dictionary_of_composers = dictionaryInit(json_file_path)
            update_json_file = updateJsonFile(
                dictionary_of_composers, json_file_path)

        shutil.copy(score_1_path, self.directory_path)
        shutil.copy(score_2_path, self.directory_path)
        shutil.copy(json_file_path, self.directory_path)
Exemplo n.º 3
0
    def testDictionaryDoesNotLoadFromEmptyJson(self):
        indices = getBoijeLetterIndices()
        dictionary_should_be = consolidateIndicesToDictionary(indices)
        boije_directory, json_file_path = boijeCollectionInit(DESTINATION_DIRECTORY, BOIJE_DIRECTORY_NAME)

        returned_dictionary = dictionaryInit(json_file_path)

        self.assertEqual(returned_dictionary, dictionary_should_be)
Exemplo n.º 4
0
    def testDictionaryLoadsFromJson(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))
        write_to_json_file = updateJsonFile(convert_index_to_dictionary, json_file_path)

        returned_dictionary = dictionaryInit(json_file_path)

        self.assertEqual(convert_index_to_dictionary, returned_dictionary)