Пример #1
0
 def test_download(self):
   file_list = ['/debian/README.html']
   ftpd = DirectHttpDownload('http', 'ftp2.fr.debian.org', '', file_list)
   (file_list, dir_list) = ftpd.list()
   ftpd.download(self.utils.data_dir, False)
   ftpd.close()
   self.assertTrue(os.path.exists(os.path.join(self.utils.data_dir,'README.html')))
Пример #2
0
 def test_download(self):
     file_list = ["/debian/README.html"]
     ftpd = DirectHttpDownload("http", "ftp2.fr.debian.org", "", file_list)
     (file_list, dir_list) = ftpd.list()
     ftpd.download(self.utils.data_dir, False)
     ftpd.close()
     self.assertTrue(os.path.exists(os.path.join(self.utils.data_dir, "README.html")))
Пример #3
0
 def test_download(self):
     file_list = ['/debian/README.html']
     ftpd = DirectHttpDownload('http', 'ftp2.fr.debian.org', '', file_list)
     (file_list, dir_list) = ftpd.list()
     ftpd.download(self.utils.data_dir, False)
     ftpd.close()
     self.assertTrue(
         os.path.exists(os.path.join(self.utils.data_dir, 'README.html')))
Пример #4
0
 def test_http_list(self):
   file_list = ['/debian/README.html']
   ftpd = DirectHttpDownload('http', 'ftp2.fr.debian.org', '', file_list)
   fday = ftpd.files_to_download[0]['day']
   fmonth = ftpd.files_to_download[0]['month']
   fyear = ftpd.files_to_download[0]['year']
   (file_list, dir_list) = ftpd.list()
   ftpd.close()
   self.assertTrue(len(file_list) == 1)
   self.assertTrue(file_list[0]['size']!=0)
   self.assertFalse(fyear == ftpd.files_to_download[0]['year'] and fmonth == ftpd.files_to_download[0]['month'] and fday == ftpd.files_to_download[0]['day'])
Пример #5
0
 def test_http_list(self):
     file_list = ['/debian/README.html']
     ftpd = DirectHttpDownload('http', 'ftp2.fr.debian.org', '', file_list)
     fday = ftpd.files_to_download[0]['day']
     fmonth = ftpd.files_to_download[0]['month']
     fyear = ftpd.files_to_download[0]['year']
     (file_list, dir_list) = ftpd.list()
     ftpd.close()
     self.assertTrue(len(file_list) == 1)
     self.assertTrue(file_list[0]['size'] != 0)
     self.assertFalse(fyear == ftpd.files_to_download[0]['year']
                      and fmonth == ftpd.files_to_download[0]['month']
                      and fday == ftpd.files_to_download[0]['day'])
Пример #6
0
 def test_download_get_params_save_as(self):
   file_list = ['/get']
   ftpd = DirectHttpDownload('http', 'httpbin.org', '', file_list)
   ftpd.param = { 'key1': 'value1', 'key2': 'value2'}
   ftpd.save_as = 'test.json'
   (file_list, dir_list) = ftpd.list()
   ftpd.download(self.utils.data_dir, False)
   ftpd.close()
   self.assertTrue(os.path.exists(os.path.join(self.utils.data_dir,'test.json')))
   with open(os.path.join(self.utils.data_dir,'test.json'), 'r') as content_file:
     content = content_file.read()
     my_json = json.loads(content)
     self.assertTrue(my_json['args']['key1'] == 'value1')
Пример #7
0
 def test_download_get_params_save_as(self):
     file_list = ["/get"]
     ftpd = DirectHttpDownload("http", "httpbin.org", "", file_list)
     ftpd.param = {"key1": "value1", "key2": "value2"}
     ftpd.save_as = "test.json"
     (file_list, dir_list) = ftpd.list()
     ftpd.download(self.utils.data_dir, False)
     ftpd.close()
     self.assertTrue(os.path.exists(os.path.join(self.utils.data_dir, "test.json")))
     with open(os.path.join(self.utils.data_dir, "test.json"), "r") as content_file:
         content = content_file.read()
         my_json = json.loads(content)
         self.assertTrue(my_json["args"]["key1"] == "value1")
Пример #8
0
 def test_download_get_params_save_as(self):
     file_list = ['/get']
     ftpd = DirectHttpDownload('http', 'httpbin.org', '', file_list)
     ftpd.param = {'key1': 'value1', 'key2': 'value2'}
     ftpd.save_as = 'test.json'
     (file_list, dir_list) = ftpd.list()
     ftpd.download(self.utils.data_dir, False)
     ftpd.close()
     self.assertTrue(
         os.path.exists(os.path.join(self.utils.data_dir, 'test.json')))
     with open(os.path.join(self.utils.data_dir, 'test.json'),
               'r') as content_file:
         content = content_file.read()
         my_json = json.loads(content)
         self.assertTrue(my_json['args']['key1'] == 'value1')
Пример #9
0
 def test_http_list(self):
     file_list = ["/debian/README.html"]
     ftpd = DirectHttpDownload("http", "ftp2.fr.debian.org", "", file_list)
     fday = ftpd.files_to_download[0]["day"]
     fmonth = ftpd.files_to_download[0]["month"]
     fyear = ftpd.files_to_download[0]["year"]
     (file_list, dir_list) = ftpd.list()
     ftpd.close()
     self.assertTrue(len(file_list) == 1)
     self.assertTrue(file_list[0]["size"] != 0)
     self.assertFalse(
         fyear == ftpd.files_to_download[0]["year"]
         and fmonth == ftpd.files_to_download[0]["month"]
         and fday == ftpd.files_to_download[0]["day"]
     )
Пример #10
0
 def test_download_post_params(self):
   #file_list = ['/debian/README.html']
   file_list = ['/post']
   ftpd = DirectHttpDownload('http', 'httpbin.org', '', file_list)
   #ftpd = DirectHttpDownload('http', 'ftp2.fr.debian.org', '', file_list)
   ftpd.param = { 'key1': 'value1', 'key2': 'value2'}
   ftpd.save_as = 'test.json'
   ftpd.method = 'POST'
   (file_list, dir_list) = ftpd.list()
   ftpd.download(self.utils.data_dir, False)
   ftpd.close()
   self.assertTrue(os.path.exists(os.path.join(self.utils.data_dir,'test.json')))
   with open(os.path.join(self.utils.data_dir,'test.json'), 'r') as content_file:
     content = content_file.read()
     my_json = json.loads(content)
     self.assertTrue(my_json['form']['key1'] == 'value1')
Пример #11
0
 def test_download_post_params(self):
     # file_list = ['/debian/README.html']
     file_list = ["/post"]
     ftpd = DirectHttpDownload("http", "httpbin.org", "", file_list)
     # ftpd = DirectHttpDownload('http', 'ftp2.fr.debian.org', '', file_list)
     ftpd.param = {"key1": "value1", "key2": "value2"}
     ftpd.save_as = "test.json"
     ftpd.method = "POST"
     (file_list, dir_list) = ftpd.list()
     ftpd.download(self.utils.data_dir, False)
     ftpd.close()
     self.assertTrue(os.path.exists(os.path.join(self.utils.data_dir, "test.json")))
     with open(os.path.join(self.utils.data_dir, "test.json"), "r") as content_file:
         content = content_file.read()
         my_json = json.loads(content)
         self.assertTrue(my_json["form"]["key1"] == "value1")
Пример #12
0
 def test_download_post_params(self):
     #file_list = ['/debian/README.html']
     file_list = ['/post']
     ftpd = DirectHttpDownload('http', 'httpbin.org', '', file_list)
     #ftpd = DirectHttpDownload('http', 'ftp2.fr.debian.org', '', file_list)
     ftpd.param = {'key1': 'value1', 'key2': 'value2'}
     ftpd.save_as = 'test.json'
     ftpd.method = 'POST'
     (file_list, dir_list) = ftpd.list()
     ftpd.download(self.utils.data_dir, False)
     ftpd.close()
     self.assertTrue(
         os.path.exists(os.path.join(self.utils.data_dir, 'test.json')))
     with open(os.path.join(self.utils.data_dir, 'test.json'),
               'r') as content_file:
         content = content_file.read()
         my_json = json.loads(content)
         self.assertTrue(my_json['form']['key1'] == 'value1')