Beispiel #1
0
 def test_execute_ng(self):
     # use url which does not exist
     url = "https://spam.com/get"
     timeout = 5
     retry_count = 1
     d = Download(url, self.__dest_path, timeout, retry_count)
     with pytest.raises(HTTPError) as execinfo:
         d.execute()
     assert "Http request failed." in str(execinfo.value)
Beispiel #2
0
 def test_execute_ok(self):
     # use Postman echo
     url = "https://postman-echo.com/get?foo1=bar1&foo2=bar2"
     timeout = 10
     retry_cnt = 3
     d = Download(url, self._dest_path, timeout, retry_cnt)
     d.execute()
     f = open("/tmp/test.result", "r")
     result = f.read()
     f.close()
     os.remove(self._dest_path)
     assert "postman-echo.com" in result
Beispiel #3
0
    def execute(self, *args):
        super().execute()

        os.makedirs(self._dest_dir, exist_ok=True)

        url = os.path.join(self._src_url, self._src_pattern)
        dest_path = (os.path.join(self._dest_dir, self._dest_pattern)
                     if self._dest_pattern else os.path.join(
                         self._dest_dir, self._src_pattern))

        d = Download(url, dest_path, self._timeout, self._retry_count)
        d.execute()