test Content-Type for static compressed files

This commit is contained in:
Ali Ebrahim 2015-07-30 13:12:56 -07:00
parent 8943ee06df
commit 3a881d9cb5
6 changed files with 42 additions and 0 deletions

View File

@ -8,6 +8,9 @@ include tornado/test/gettext_translations/fr_FR/LC_MESSAGES/tornado_test.mo
include tornado/test/gettext_translations/fr_FR/LC_MESSAGES/tornado_test.po
include tornado/test/options_test.cfg
include tornado/test/static/robots.txt
include tornado/test/static/sample.xml
include tornado/test/static/sample.xml.gz
include tornado/test/static/sample.xml.bz2
include tornado/test/static/dir/index.html
include tornado/test/static_foo.txt
include tornado/test/templates/utf8.html

View File

@ -146,6 +146,9 @@ setup(
"gettext_translations/fr_FR/LC_MESSAGES/tornado_test.po",
"options_test.cfg",
"static/robots.txt",
"static/sample.xml",
"static/sample.xml.gz",
"static/sample.xml.bz2",
"static/dir/index.html",
"static_foo.txt",
"templates/utf8.html",

View File

@ -0,0 +1,23 @@
<?xml version="1.0"?>
<data>
<country name="Liechtenstein">
<rank>1</rank>
<year>2008</year>
<gdppc>141100</gdppc>
<neighbor name="Austria" direction="E"/>
<neighbor name="Switzerland" direction="W"/>
</country>
<country name="Singapore">
<rank>4</rank>
<year>2011</year>
<gdppc>59900</gdppc>
<neighbor name="Malaysia" direction="N"/>
</country>
<country name="Panama">
<rank>68</rank>
<year>2011</year>
<gdppc>13600</gdppc>
<neighbor name="Costa Rica" direction="W"/>
<neighbor name="Colombia" direction="E"/>
</country>
</data>

Binary file not shown.

Binary file not shown.

View File

@ -978,6 +978,19 @@ class StaticFileTest(WebTestCase):
response = self.fetch('/static/robots.txt')
self.assertTrue(b"Disallow: /" in response.body)
self.assertEqual(response.headers.get("Content-Type"), "text/plain")
def test_static_compressed_files(self):
response = self.fetch("/static/sample.xml.gz")
self.assertEqual(response.headers.get("Content-Type"),
"application/gzip")
response = self.fetch("/static/sample.xml.bz2")
self.assertEqual(response.headers.get("Content-Type"),
"application/octet-stream")
# make sure the uncompressed file still has the correct type
response = self.fetch("/static/sample.xml")
self.assertTrue(response.headers.get("Content-Type")
in set(("text/xml", "application/xml")))
def test_static_url(self):
response = self.fetch("/static_url/robots.txt")