Rename route match groups for consistency, refs #1667, #1660

This commit is contained in:
Simon Willison 2022-03-19 09:52:08 -07:00
commit 61419388c1
8 changed files with 36 additions and 40 deletions

View file

@ -12,26 +12,26 @@ def routes():
@pytest.mark.parametrize(
"path,expected_class,expected_matches",
(
("/", "IndexView", {"as_format": ""}),
("/foo", "DatabaseView", {"as_format": None, "db_name": "foo"}),
("/foo.csv", "DatabaseView", {"as_format": ".csv", "db_name": "foo"}),
("/foo.json", "DatabaseView", {"as_format": ".json", "db_name": "foo"}),
("/foo.humbug", "DatabaseView", {"as_format": None, "db_name": "foo.humbug"}),
("/foo/humbug", "TableView", {"db_name": "foo", "table": "humbug"}),
("/foo/humbug.json", "TableView", {"db_name": "foo", "table": "humbug"}),
("/foo/humbug.blah", "TableView", {"db_name": "foo", "table": "humbug"}),
("/", "IndexView", {"format": ""}),
("/foo", "DatabaseView", {"format": None, "database": "foo"}),
("/foo.csv", "DatabaseView", {"format": ".csv", "database": "foo"}),
("/foo.json", "DatabaseView", {"format": ".json", "database": "foo"}),
("/foo.humbug", "DatabaseView", {"format": None, "database": "foo.humbug"}),
("/foo/humbug", "TableView", {"database": "foo", "table": "humbug"}),
("/foo/humbug.json", "TableView", {"database": "foo", "table": "humbug"}),
("/foo/humbug.blah", "TableView", {"database": "foo", "table": "humbug"}),
(
"/foo/humbug/1",
"RowView",
{"as_format": None, "db_name": "foo", "pk_path": "1", "table": "humbug"},
{"format": None, "database": "foo", "pks": "1", "table": "humbug"},
),
(
"/foo/humbug/1.json",
"RowView",
{"as_format": ".json", "db_name": "foo", "pk_path": "1", "table": "humbug"},
{"format": ".json", "database": "foo", "pks": "1", "table": "humbug"},
),
("/-/metadata.json", "JsonDataView", {"as_format": ".json"}),
("/-/metadata", "JsonDataView", {"as_format": ""}),
("/-/metadata.json", "JsonDataView", {"format": ".json"}),
("/-/metadata", "JsonDataView", {"format": ""}),
),
)
def test_routes(routes, path, expected_class, expected_matches):