Exemplo n.º 1
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'])
Exemplo n.º 2
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'])
Exemplo n.º 3
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"]
     )
Exemplo n.º 4
0
 def test_download_save_as(self):
     file_list = ['/debian/README.html']
     ftpd = DirectHttpDownload('http', 'ftp2.fr.debian.org', '', file_list)
     ftpd.save_as = 'test.html'
     (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.html')))
Exemplo n.º 5
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')
Exemplo n.º 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')
Exemplo n.º 7
0
 def test_download_save_as(self):
   file_list = ['/debian/README.html']
   ftpd = DirectHttpDownload('http', 'ftp2.fr.debian.org', '', file_list)
   ftpd.save_as = 'test.html'
   (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.html')))
Exemplo n.º 8
0
 def test_download_save_as(self):
     file_list = ["/debian/README.html"]
     ftpd = DirectHttpDownload("http", "ftp2.fr.debian.org", "", file_list)
     ftpd.save_as = "test.html"
     (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.html")))
Exemplo n.º 9
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')
Exemplo n.º 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")
Exemplo n.º 11
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')
Exemplo n.º 12
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")