コード例 #1
0
ファイル: test_curlDownload.py プロジェクト: zaratozom/pyload
class TestCurlRequest(TestCase):

    cookieURL = "http://forum.pyload.org"

    def setUp(self):
        self.dl = CurlDownload(Bucket())

    def tearDown(self):
        self.dl.close()

    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
        assert self.dl.speed == 0
        assert self.dl.arrived == 0
コード例 #2
0
ファイル: test_curlDownload.py プロジェクト: zaratozom/pyload
    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)
コード例 #3
0
ファイル: test_curlDownload.py プロジェクト: DasLampe/pyload
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
コード例 #4
0
ファイル: test_curlDownload.py プロジェクト: zaratozom/pyload
 def setUp(self):
     self.dl = CurlDownload(Bucket())