Add another test to httpdownloader.

Make it compatible with python 2.5.
This commit is contained in:
John Garland 2009-12-21 13:48:00 +00:00
parent c7d52f3ce5
commit 5a8c443d50

View file

@ -4,6 +4,8 @@ from twisted.python.failure import Failure
from deluge.httpdownloader import download_file
from deluge.log import setupLogger
from email.utils import formatdate
class DownloadFileTestCase(unittest.TestCase):
def setUp(self):
setupLogger("warning", "log_file")
@ -12,8 +14,11 @@ class DownloadFileTestCase(unittest.TestCase):
pass
def assertContains(self, filename, contents):
with open(filename) as f:
f = open(filename)
try:
self.assertEqual(f.read(), contents)
finally:
f.close()
return filename
def test_download(self):
@ -82,3 +87,10 @@ class DownloadFileTestCase(unittest.TestCase):
d.addCallback(self.fail)
d.addErrback(self.assertIsInstance, Failure)
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