diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-07-19 19:36:05 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-07-19 19:36:17 +0200 |
commit | 873f91be7d3316e93672731e2f3d2da02b41fca6 (patch) | |
tree | 5a12d1a5ac1f0a4aa5fca9ab9e6b86e64f25e388 /tests/other | |
parent | Explain how to add tips for translators (diff) | |
download | pyload-873f91be7d3316e93672731e2f3d2da02b41fca6.tar.xz |
new plugin type and refactored request classes
Diffstat (limited to 'tests/other')
-rw-r--r-- | tests/other/test_curlDownload.py | 30 | ||||
-rw-r--r-- | tests/other/test_curlRequest.py | 28 | ||||
-rw-r--r-- | tests/other/test_requestFactory.py | 30 |
3 files changed, 88 insertions, 0 deletions
diff --git a/tests/other/test_curlDownload.py b/tests/other/test_curlDownload.py new file mode 100644 index 000000000..d3f8f6754 --- /dev/null +++ b/tests/other/test_curlDownload.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +from os import stat +from os.path import exists + +from tests.helper.Stubs import Core +from pyload.network.Bucket import Bucket +from pyload.plugins.network.CurlDownload import CurlDownload + +class TestCurlRequest: + + def setUp(self): + self.dl = CurlDownload(Bucket()) + + def tearDown(self): + self.dl.close() + + def test_download(self): + + self.dl.download("http://pyload.org/lib/tpl/pyload/images/pyload-logo-edited3.5-new-font-small.png", "/tmp/random.bin") + + print self.dl.size, self.dl.arrived + assert self.dl.size == self.dl.arrived > 0 + assert stat("/tmp/random.bin").st_size == self.dl.size + + + def test_attributes(self): + assert self.dl.size == 0 + assert self.dl.speed == 0 + assert self.dl.arrived == 0
\ No newline at end of file diff --git a/tests/other/test_curlRequest.py b/tests/other/test_curlRequest.py new file mode 100644 index 000000000..0982d896d --- /dev/null +++ b/tests/other/test_curlRequest.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +from tests.helper.Stubs import Core +from pyload.plugins.network.CurlRequest import CurlRequest + + +class TestCurlRequest: + + def setUp(self): + self.req = CurlRequest({}) + + def tearDown(self): + self.req.close() + + def test_load(self): + self.req.load("http://pyload.org") + + def test_cookies(self): + + self.req.load("http://pyload.org", cookies=False) + assert len(self.req.cj.values()) == 0 + + self.req.load("http://pyload.org") + assert len(self.req.cj.values()) > 0 + + def test_auth(self): + + pass
\ No newline at end of file diff --git a/tests/other/test_requestFactory.py b/tests/other/test_requestFactory.py new file mode 100644 index 000000000..734d9c1fb --- /dev/null +++ b/tests/other/test_requestFactory.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +from tests.helper.Stubs import Core + +from pyload.plugins.network.CurlRequest import CurlRequest +from pyload.network.RequestFactory import RequestFactory + +class TestRequestFactory: + + @classmethod + def setUpClass(cls): + cls.req = RequestFactory(Core()) + + def test_get_request(self): + req = self.req.getRequest() + + new_req = self.req.getRequest(req.getContext()) + assert new_req.getContext() == req.getContext() + + def test_get_request_class(self): + + self.req.getRequest(None, CurlRequest) + + def test_get_download(self): + dl = self.req.getDownloadRequest() + dl.close() + + # with given request + dl = self.req.getDownloadRequest(self.req.getRequest()) + dl.close()
\ No newline at end of file |