def test_view(mount, context): root = Path(mount.backend.root) path = context.path (root / path / "childdir").mkdir(parents=True) with (root / path / "childfile").open("w") as f: pass request = DummyRequest() request.collator = DummyCollator() resp = directory_view(context, request) assert not resp["show_hidden"] assert resp["parents"] == [ (mount.name, "../../"), (path.parts[0], "../"), ] children = resp["children"] assert len(children) == 2 child = children[0] assert child.name == "childdir" assert isinstance(child, Directory) child = children[1] assert child.name == "childfile" assert isinstance(child, File)
def test_view_redirect_trailing_slash(): request = DummyRequest(path="/foo/bar") with raises(HTTPSeeOther) as exc_info: directory_view(None, request) print(request.url) assert exc_info.value.location.endswith(request.path + "/")