Beispiel #1
0
 def test_write_binary(self):
     """ Test can_include_file()
     """
     Files.write_binary("test", "binary.bin", TEST_PATH)
     self.assertTrue(Files.file_exists(TEST_PATH + "binary.bin"))
     content = Files.get_raw_contents(TEST_PATH + "binary.bin")
     self.assertTrue(content == "74657374")
     Files.delete_files(TEST_PATH + "binary.bin")
Beispiel #2
0
    def test_get_raw_contents(self):
        """ Test get_raw_contents()
        """

        Files.write("some content", "file1.txt", TEST_PATH)
        content = Files.get_raw_contents(TEST_PATH + "file1.txt")
        self.assertTrue(content == "some content")
        Files.delete_files(TEST_PATH + "file1.txt")
Beispiel #3
0
    def download(self):
        """ Download HTML web pages
        """

        if self.debug:
            print "  Downloading: %s" % self.test_file + FILE_EXT_HTML
            url_list = [self.base_url + self.test_file + FILE_EXT_HTML]
        else:
            url_list = Files.get_raw_contents(self.name + ".urls", "./")

        for web_file in url_list:
            cached_file = web_file.replace(self.base_url, "")
            if not Files.file_exists(self.download_folder + cached_file):
                data = Download.download_page(web_file)
                Files.write(data, cached_file, self.download_folder)
            elif self.debug:
                print "    File %s already exists" % (self.download_folder +
                                                      cached_file)