add method to from resource path to request path
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
import pytest
|
||||
from werkzeug.http import dump_cookie
|
||||
|
||||
from incorporealcms.pages import (generate_parent_navs, render, request_path_to_instance_resource_path,
|
||||
resolve_page_file)
|
||||
from incorporealcms.pages import (generate_parent_navs, instance_resource_path_to_request_path, render,
|
||||
request_path_to_instance_resource_path, resolve_page_file)
|
||||
|
||||
|
||||
def test_resolve_page_file_dir_to_index():
|
||||
@@ -146,3 +146,39 @@ def test_request_path_to_instance_resource_path_absolute_file_errors(app):
|
||||
with app.test_request_context():
|
||||
with pytest.raises(PermissionError):
|
||||
assert request_path_to_instance_resource_path('/etc/hosts')
|
||||
|
||||
|
||||
def test_instance_resource_path_to_request_path_on_index(app):
|
||||
"""Test index.md -> /."""
|
||||
with app.test_request_context():
|
||||
assert instance_resource_path_to_request_path('index.md') == ''
|
||||
|
||||
|
||||
def test_instance_resource_path_to_request_path_on_page(app):
|
||||
"""Test no-title.md -> no-title."""
|
||||
with app.test_request_context():
|
||||
assert instance_resource_path_to_request_path('no-title.md') == 'no-title'
|
||||
|
||||
|
||||
def test_instance_resource_path_to_request_path_on_subdir(app):
|
||||
"""Test subdir/index.md -> subdir/."""
|
||||
with app.test_request_context():
|
||||
assert instance_resource_path_to_request_path('subdir/index.md') == 'subdir/'
|
||||
|
||||
|
||||
def test_instance_resource_path_to_request_path_on_subdir_and_page(app):
|
||||
"""Test subdir/page.md -> subdir/page."""
|
||||
with app.test_request_context():
|
||||
assert instance_resource_path_to_request_path('subdir/page.md') == 'subdir/page'
|
||||
|
||||
|
||||
def test_request_resource_request_root(app):
|
||||
"""Test that a request can resolve to a resource and back to a request."""
|
||||
with app.test_request_context():
|
||||
instance_resource_path_to_request_path(request_path_to_instance_resource_path('index')) == ''
|
||||
|
||||
|
||||
def test_request_resource_request_page(app):
|
||||
"""Test that a request can resolve to a resource and back to a request."""
|
||||
with app.test_request_context():
|
||||
instance_resource_path_to_request_path(request_path_to_instance_resource_path('no-title')) == 'no-title'
|
||||
|
||||
Reference in New Issue
Block a user