mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 11:35:49 +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.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
|
||||
|
|
Loading…
Add table
Reference in a new issue