Example #1
0
 def get_download_filename(self):
     if self.rep_type == Constants.REPOSITORY_TYPE_GIT:
         return GitUtil.get_repository_name(self.rep_path)
     elif self.rep_type == Constants.REPOSITORY_TYPE_LOCAL:
         _, filename = os.path.split(self.rep_path)
         return slugify(filename)
     elif self.rep_type == Constants.REPOSITORY_TYPE_ZIP:
         filename = DownloadUtil.get_filename_from_url(self.rep_path)
         return filename
     elif self.rep_type == Constants.REPOSITORY_TYPE_TAR:
         filename = DownloadUtil.get_filename_from_url(self.rep_path)
         return filename
     else:
         return ''
Example #2
0
    def test_download_file(self, d):
        os.chdir(d.path)

        download_url = 'https://raw.githubusercontent.com/ezored/ezored/master/extras/images/jetbrains-logo.png'
        download_filename = DownloadUtil.get_filename_from_url(download_url)

        DownloadUtil.download_file(download_url)

        self.assertTrue(os.path.isfile(download_filename))
        self.assertEqual(os.path.getsize(download_filename), 5627)
Example #3
0
    def test_download_file_with_custom_destination(self, d):
        os.chdir(d.path)

        download_url = 'https://raw.githubusercontent.com/ezored/ezored/master/extras/images/jetbrains-logo.png'
        download_dest = 'download'
        download_filename = DownloadUtil.get_filename_from_url(download_url)

        os.mkdir(download_dest)

        DownloadUtil.download_file(download_url, download_dest)

        self.assertTrue(os.path.isfile(os.path.join(download_dest, download_filename)))
        self.assertEqual(os.path.getsize(os.path.join(download_dest, download_filename)), 5627)
Example #4
0
    def test_get_filename_from_url(self):
        download_url = 'https://raw.githubusercontent.com/ezored/ezored/master/extras/images/jetbrains-logo.png'
        download_filename = DownloadUtil.get_filename_from_url(download_url)

        self.assertEqual(download_filename, 'jetbrains-logo.png')