?_extra= support and TableView refactor to table_view

* Implemented ?_extra= option for JSON views, refs #262
* New dependency: asyncinject
* Remove now-obsolete TableView class
This commit is contained in:
Simon Willison 2023-03-22 15:49:39 -07:00 committed by GitHub
commit d97e82df3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 1593 additions and 1085 deletions

View file

@ -11,7 +11,7 @@ def routes():
@pytest.mark.parametrize(
"path,expected_class,expected_matches",
"path,expected_name,expected_matches",
(
("/", "IndexView", {"format": None}),
("/foo", "DatabaseView", {"format": None, "database": "foo"}),
@ -20,17 +20,17 @@ def routes():
("/foo.humbug", "DatabaseView", {"format": "humbug", "database": "foo"}),
(
"/foo/humbug",
"TableView",
"table_view",
{"database": "foo", "table": "humbug", "format": None},
),
(
"/foo/humbug.json",
"TableView",
"table_view",
{"database": "foo", "table": "humbug", "format": "json"},
),
(
"/foo/humbug.blah",
"TableView",
"table_view",
{"database": "foo", "table": "humbug", "format": "blah"},
),
(
@ -47,12 +47,14 @@ def routes():
("/-/metadata", "JsonDataView", {"format": None}),
),
)
def test_routes(routes, path, expected_class, expected_matches):
def test_routes(routes, path, expected_name, expected_matches):
match, view = resolve_routes(routes, path)
if expected_class is None:
if expected_name is None:
assert match is None
else:
assert view.view_class.__name__ == expected_class
assert (
view.__name__ == expected_name or view.view_class.__name__ == expected_name
)
assert match.groupdict() == expected_matches