@@ -29,12 +29,15 @@ def teardown():
29
29
return tmp_dir
30
30
31
31
32
+ @pytest .mark .parametrize ("show_index,status" , [(False , 403 ), (True , 200 )])
32
33
@pytest .mark .run_loop
33
- def test_access_root_of_static_handler (tmp_dir_path , create_app_and_client ):
34
+ def test_access_root_of_static_handler (tmp_dir_path , create_app_and_client ,
35
+ show_index , status ):
34
36
"""
35
37
Tests the operation of static file server.
36
38
Try to access the root of static file server, and make
37
- sure that a `HTTP 403 - Forbidden` is returned.
39
+ sure that correct HTTP statuses are returned depending if we directory
40
+ index should be shown or not.
38
41
"""
39
42
# Put a file inside tmp_dir_path:
40
43
my_file_path = os .path .join (tmp_dir_path , 'my_file' )
@@ -44,12 +47,12 @@ def test_access_root_of_static_handler(tmp_dir_path, create_app_and_client):
44
47
app , client = yield from create_app_and_client ()
45
48
46
49
# Register global static route:
47
- app .router .add_static ('/' , tmp_dir_path )
50
+ app .router .add_static ('/' , tmp_dir_path , show_index = show_index )
48
51
49
52
# Request the root of the static directory.
50
53
# Expect an 403 error page.
51
54
r = yield from client .get ('/' )
52
- assert r .status == 403
55
+ assert r .status == status
53
56
# data = (yield from r.read())
54
57
yield from r .release ()
55
58
0 commit comments