diff options
Diffstat (limited to 'test/test_sendfile.py')
-rwxr-xr-x | test/test_sendfile.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/test/test_sendfile.py b/test/test_sendfile.py index bf951f5..9d708e4 100755 --- a/test/test_sendfile.py +++ b/test/test_sendfile.py @@ -42,17 +42,17 @@ class TestSendFile(unittest.TestCase): def test_valid(self): """ SendFile: Valid requests""" out = static_file(os.path.basename(__file__), root='./') - self.assertEqual(open(__file__,'rb').read(), out.output.read()) + self.assertEqual(open(__file__,'rb').read(), out.body.read()) def test_invalid(self): """ SendFile: Invalid requests""" - self.assertEqual(404, static_file('not/a/file', root='./').status) + self.assertEqual(404, static_file('not/a/file', root='./').status_code) f = static_file(os.path.join('./../', os.path.basename(__file__)), root='./views/') - self.assertEqual(403, f.status) + self.assertEqual(403, f.status_code) try: fp, fn = tempfile.mkstemp() os.chmod(fn, 0) - self.assertEqual(403, static_file(fn, root='/').status) + self.assertEqual(403, static_file(fn, root='/').status_code) finally: os.close(fp) os.unlink(fn) @@ -70,7 +70,7 @@ class TestSendFile(unittest.TestCase): request.environ['HTTP_IF_MODIFIED_SINCE'] = \ time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime()) res = static_file(os.path.basename(__file__), root='./') - self.assertEqual(304, res.status) + self.assertEqual(304, res.status_code) self.assertEqual(int(os.stat(__file__).st_mtime), parse_date(res.headers['Last-Modified'])) self.assertAlmostEqual(int(time.time()), @@ -78,7 +78,7 @@ class TestSendFile(unittest.TestCase): with self.context: request.environ['HTTP_IF_MODIFIED_SINCE'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(100)) res = static_file(os.path.basename(__file__), root='./') - self.assertEqual(open(__file__,'rb').read(), res.output.read()) + self.assertEqual(open(__file__,'rb').read(), res.body.read()) def test_download(self): """ SendFile: Download as attachment """ @@ -89,7 +89,7 @@ class TestSendFile(unittest.TestCase): request.environ['HTTP_IF_MODIFIED_SINCE'] =\ time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(100)) f = static_file(os.path.basename(__file__), root='./') - self.assertEqual(open(__file__,'rb').read(), f.output.read()) + self.assertEqual(open(__file__,'rb').read(), f.body.read()) def test_range(self): basename = os.path.basename(__file__) @@ -97,11 +97,11 @@ class TestSendFile(unittest.TestCase): request.environ['HTTP_RANGE'] = 'bytes=10-25,-80' f = static_file(basename, root='./') c = open(basename, 'rb'); c.seek(10) - self.assertEqual(c.read(16), tob('').join(f.output)) + self.assertEqual(c.read(16), tob('').join(f.body)) self.assertEqual('bytes 10-25/%d' % len(open(basename, 'rb').read()), f.headers['Content-Range']) self.assertEqual('bytes', f.headers['Accept-Ranges']) - + def test_range_parser(self): r = lambda rs: list(parse_range_header(rs, 100)) self.assertEqual([(90, 100)], r('bytes=-10')) |