コード例 #1
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)
コード例 #2
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)
コード例 #3
0
    def testRetrieveScore(self):
        full_url = 'http://biblioteket.statensmusikverk.se/ebibliotek/boije/%s'%self.html

        downloaded_score = getScorePDF(self.html)
        score_pdf = downloaded_score.content
        status_code = downloaded_score.status_code

        #All pdfs start with PDF in the beginning
        self.assertEqual(full_url, downloaded_score.url)
        self.assertEqual(200, status_code)
        self.assertIn('%PDF-', score_pdf[0:5])