summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/other/test_curlDownload.py29
-rw-r--r--tests/other/test_curlRequest.py11
2 files changed, 34 insertions, 6 deletions
diff --git a/tests/other/test_curlDownload.py b/tests/other/test_curlDownload.py
index d3f8f6754..17af1cdd4 100644
--- a/tests/other/test_curlDownload.py
+++ b/tests/other/test_curlDownload.py
@@ -1,13 +1,17 @@
# -*- coding: utf-8 -*-
from os import stat
-from os.path import exists
+
+from unittest import TestCase
from tests.helper.Stubs import Core
from pyload.network.Bucket import Bucket
+from pyload.plugins.network.CurlRequest import CurlRequest
from pyload.plugins.network.CurlDownload import CurlDownload
-class TestCurlRequest:
+class TestCurlRequest(TestCase):
+
+ cookieURL = "http://forum.pyload.org"
def setUp(self):
self.dl = CurlDownload(Bucket())
@@ -17,12 +21,33 @@ class TestCurlRequest:
def test_download(self):
+ assert self.dl.context is not None
+
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_cookies(self):
+
+ req = CurlRequest({})
+ req.load(self.cookieURL)
+
+ assert len(req.cj) > 0
+
+ dl = CurlDownload(Bucket(), req)
+
+ assert req.context is dl.context is not None
+
+ dl.download(self.cookieURL + "/cookies.php", "cookies.txt")
+ cookies = open("cookies.txt", "rb").read().splitlines()
+
+ self.assertEqual(len(cookies), len(dl.context))
+ for c in cookies:
+ k, v = c.strip().split(":")
+ self.assertIn(k, req.cj)
+
def test_attributes(self):
assert self.dl.size == 0
diff --git a/tests/other/test_curlRequest.py b/tests/other/test_curlRequest.py
index 09d65b385..6bd4a2772 100644
--- a/tests/other/test_curlRequest.py
+++ b/tests/other/test_curlRequest.py
@@ -21,16 +21,19 @@ class TestCurlRequest(TestCase):
def test_cookies(self):
self.req.load(self.cookieURL, cookies=False)
- assert len(self.req.cj.values()) == 0
+ assert len(self.req.cj) == 0
self.req.load(self.cookieURL)
- assert len(self.req.cj.values()) > 0
+ assert len(self.req.cj) > 1
- for c in self.req.load(self.cookieURL + "/cookies.php").splitlines():
- k, v = c.strip().split(":")
+ cookies = dict([c.strip().split(":") for c in self.req.load(self.cookieURL + "/cookies.php").splitlines()])
+ for k, v in cookies.iteritems():
self.assertIn(k, self.req.cj)
self.assertEqual(v, self.req.cj[k].value)
+ for c in self.req.cj:
+ self.assertIn(c, cookies)
+
cookies = self.req.load(self.cookieURL + "/cookies.php", cookies=False)
self.assertEqual(cookies, "")