summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2019-12-23 11:55:45 -0600
committerGitHub <noreply@github.com>2019-12-23 11:55:45 -0600
commit68d86dae5dd30a667e5f98a370517a7b82c24024 (patch)
treeebef682d7393d673364540ea35836e623c03e9cf /tests
parent5e7f4e10f45e78afe04e18c9f904aebff2d9d6b4 (diff)
parent3f42e5f2c848e69f282337f6fbf56e69b295b58e (diff)
downloadpyramid-68d86dae5dd30a667e5f98a370517a7b82c24024.tar.gz
pyramid-68d86dae5dd30a667e5f98a370517a7b82c24024.tar.bz2
pyramid-68d86dae5dd30a667e5f98a370517a7b82c24024.zip
Merge pull request #9 from stevepiercy/min-py36-add-py38
Update docs and setup.py, remove py35, py36, add py38
Diffstat (limited to 'tests')
-rw-r--r--tests/fixtures/static/only_encoded.html.gzbin0 -> 187 bytes
-rw-r--r--tests/test_static.py80
2 files changed, 80 insertions, 0 deletions
diff --git a/tests/fixtures/static/only_encoded.html.gz b/tests/fixtures/static/only_encoded.html.gz
new file mode 100644
index 000000000..afcc25768
--- /dev/null
+++ b/tests/fixtures/static/only_encoded.html.gz
Binary files differ
diff --git a/tests/test_static.py b/tests/test_static.py
index 3d0deda3f..7b6e74a64 100644
--- a/tests/test_static.py
+++ b/tests/test_static.py
@@ -458,6 +458,86 @@ class Test_static_view_content_encodings(unittest.TestCase):
self.assertEqual(res.headers['Content-Encoding'], 'gzip')
self.assertEqual(len(res.body), 187)
+ def test_call_for_encoded_variant_without_unencoded_variant_no_accept(
+ self,
+ ):
+ inst = self._makeOne(
+ 'tests:fixtures/static', content_encodings=['gzip']
+ )
+ request = self._makeRequest({'PATH_INFO': '/only_encoded.html.gz'})
+ context = DummyContext()
+
+ res = inst(context, request)
+ self.assertNotIn('Vary', res.headers)
+ self.assertNotIn('Content-Encoding', res.headers)
+ self.assertEqual(len(res.body), 187)
+
+ def test_call_for_encoded_variant_without_unencoded_variant_with_accept(
+ self,
+ ):
+ inst = self._makeOne(
+ 'tests:fixtures/static', content_encodings=['gzip']
+ )
+ request = self._makeRequest(
+ {
+ 'PATH_INFO': '/only_encoded.html.gz',
+ 'HTTP_ACCEPT_ENCODING': 'gzip',
+ }
+ )
+ context = DummyContext()
+
+ res = inst(context, request)
+ self.assertNotIn('Vary', res.headers)
+ self.assertNotIn('Content-Encoding', res.headers)
+ self.assertEqual(len(res.body), 187)
+
+ def test_call_for_unencoded_variant_with_only_encoded_variant_no_accept(
+ self,
+ ):
+ from pyramid.httpexceptions import HTTPNotFound
+
+ inst = self._makeOne(
+ 'tests:fixtures/static', content_encodings=['gzip']
+ )
+ request = self._makeRequest({'PATH_INFO': '/only_encoded.html'})
+ context = DummyContext()
+
+ self.assertRaises(HTTPNotFound, lambda: inst(context, request))
+
+ def test_call_for_unencoded_variant_with_only_encoded_variant_with_accept(
+ self,
+ ):
+ inst = self._makeOne(
+ 'tests:fixtures/static', content_encodings=['gzip']
+ )
+ request = self._makeRequest(
+ {
+ 'PATH_INFO': '/only_encoded.html',
+ 'HTTP_ACCEPT_ENCODING': 'gzip',
+ }
+ )
+ context = DummyContext()
+
+ res = inst(context, request)
+ self.assertNotIn('Vary', res.headers)
+ self.assertEqual(res.headers['Content-Encoding'], 'gzip')
+ self.assertEqual(len(res.body), 187)
+
+ def test_call_for_unencoded_variant_with_only_encoded_variant_bad_accept(
+ self,
+ ):
+ from pyramid.httpexceptions import HTTPNotFound
+
+ inst = self._makeOne(
+ 'tests:fixtures/static', content_encodings=['gzip']
+ )
+ request = self._makeRequest(
+ {'PATH_INFO': '/only_encoded.html', 'HTTP_ACCEPT_ENCODING': 'br'}
+ )
+ context = DummyContext()
+
+ self.assertRaises(HTTPNotFound, lambda: inst(context, request))
+
def test_call_get_possible_files_is_cached(self):
inst = self._makeOne('tests:fixtures/static')
result1 = inst.get_possible_files('tests:fixtures/static/encoded.html')