add tests for subdir symlinks

this is automagically supported by the previous rewrite
This commit is contained in:
Brian S. Stephan 2021-04-17 10:39:05 -05:00
parent 60715a3a5c
commit 30b79e9dc1
2 changed files with 16 additions and 0 deletions

View File

@ -139,6 +139,15 @@ def test_that_request_to_symlink_redirects_directory(client):
assert response.status_code == 200
def test_that_request_to_symlink_redirects_subdirectory(client):
"""Test that a request to /foo/bar redirects to /what-foo-points-at/bar."""
response = client.get('/symlink-to-subdir/page-no-title')
assert response.status_code == 301
assert response.location == 'http://localhost/subdir/page-no-title'
response = client.get('/subdir/page-no-title')
assert response.status_code == 200
def test_that_dir_request_does_not_redirect(client):
"""Test that a request to /foo/ serves the index page, if foo is a directory."""
response = client.get('/subdir/')

View File

@ -153,6 +153,13 @@ def test_request_path_to_instance_resource_path_dir_symlink(app):
('pages/subdir', 'symlink'))
def test_request_path_to_instance_resource_path_subdir_symlink(app):
"""Test that a request for e.g. '/foo/baz' when /foo is a symlink to /bar redirects."""
with app.test_request_context():
assert (request_path_to_instance_resource_path('symlink-to-subdir/page-no-title') ==
('pages/subdir/page-no-title.md', 'symlink'))
def test_request_path_to_instance_resource_path_nonexistant_file_errors(app):
"""Test that a request for something not on disk errors."""
with app.test_request_context():