mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-04 15:38:43 +00:00
Add another test to httpdownloader.
Make it compatible with python 2.5.
This commit is contained in:
parent
c7d52f3ce5
commit
5a8c443d50
1 changed files with 13 additions and 1 deletions
|
@ -4,6 +4,8 @@ from twisted.python.failure import Failure
|
||||||
from deluge.httpdownloader import download_file
|
from deluge.httpdownloader import download_file
|
||||||
from deluge.log import setupLogger
|
from deluge.log import setupLogger
|
||||||
|
|
||||||
|
from email.utils import formatdate
|
||||||
|
|
||||||
class DownloadFileTestCase(unittest.TestCase):
|
class DownloadFileTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
setupLogger("warning", "log_file")
|
setupLogger("warning", "log_file")
|
||||||
|
@ -12,8 +14,11 @@ class DownloadFileTestCase(unittest.TestCase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def assertContains(self, filename, contents):
|
def assertContains(self, filename, contents):
|
||||||
with open(filename) as f:
|
f = open(filename)
|
||||||
|
try:
|
||||||
self.assertEqual(f.read(), contents)
|
self.assertEqual(f.read(), contents)
|
||||||
|
finally:
|
||||||
|
f.close()
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
def test_download(self):
|
def test_download(self):
|
||||||
|
@ -82,3 +87,10 @@ class DownloadFileTestCase(unittest.TestCase):
|
||||||
d.addCallback(self.fail)
|
d.addCallback(self.fail)
|
||||||
d.addErrback(self.assertIsInstance, Failure)
|
d.addErrback(self.assertIsInstance, Failure)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def test_page_not_modified(self):
|
||||||
|
headers = { 'If-Modified-Since' : formatdate(usegmt=True) }
|
||||||
|
d = download_file("http://deluge-torrent.org", "index.html", headers=headers)
|
||||||
|
d.addCallback(self.fail)
|
||||||
|
d.addErrback(self.assertIsInstance, Failure)
|
||||||
|
return d
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue