diff --git a/tests/test_httpdownloader.py b/tests/test_httpdownloader.py index 0659bd091..d86e74c51 100644 --- a/tests/test_httpdownloader.py +++ b/tests/test_httpdownloader.py @@ -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