summaryrefslogtreecommitdiffhomepage
path: root/test/test_static.py
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2022-02-21 23:02:51 +0100
committerAlejandro Colomar <alx.manpages@gmail.com>2022-05-30 12:42:18 +0200
commit8027e7ce0f3c7558647661864fd742d9afb33374 (patch)
tree73cf8d1f0f4472a5924747dba7936b197f3542a6 /test/test_static.py
parent9af5f369511eefea691a5cb6787a31ef3af53a0a (diff)
downloadunit-8027e7ce0f3c7558647661864fd742d9afb33374.tar.gz
unit-8027e7ce0f3c7558647661864fd742d9afb33374.tar.bz2
Tests: added tests for "index" (string) option.
Diffstat (limited to 'test/test_static.py')
-rw-r--r--test/test_static.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_static.py b/test/test_static.py
index 5ec49f38..b9c78fdd 100644
--- a/test/test_static.py
+++ b/test/test_static.py
@@ -87,6 +87,22 @@ class TestStatic(TestApplicationProto):
assert self.get(url='/')['body'] == '0123456789', 'before 1.26.0 2'
def test_static_index(self):
+ def set_index(index):
+ assert 'success' in self.conf(
+ {"share": option.temp_dir + "/assets$uri", "index": index},
+ 'routes/0/action',
+ ), 'configure index'
+
+ set_index('README')
+ assert self.get()['body'] == 'readme', 'index'
+
+ self.conf_delete('routes/0/action/index')
+ assert self.get()['body'] == '0123456789', 'delete index'
+
+ set_index('')
+ assert self.get()['status'] == 404, 'index empty'
+
+ def test_static_index_default(self):
assert self.get(url='/index.html')['body'] == '0123456789', 'index'
assert self.get(url='/')['body'] == '0123456789', 'index 2'
assert self.get(url='//')['body'] == '0123456789', 'index 3'
@@ -102,6 +118,18 @@ class TestStatic(TestApplicationProto):
resp['headers']['Content-Type'] == 'text/html'
), 'index not found 2 Content-Type'
+ def test_static_index_invalid(self, skip_alert):
+ skip_alert(r'failed to apply new conf')
+
+ def check_index(index):
+ assert 'error' in self.conf(
+ {"share": option.temp_dir + "/assets$uri", "index": index},
+ 'routes/0/action',
+ )
+
+ check_index({})
+ check_index(['index.html', '$blah'])
+
def test_static_large_file(self, temp_dir):
file_size = 32 * 1024 * 1024
with open(temp_dir + '/assets/large', 'wb') as f: