mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
parent
4e47a2d894
commit
711767bcd3
3 changed files with 72 additions and 24 deletions
34
tests/test_routes.py
Normal file
34
tests/test_routes.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from datasette.app import Datasette
|
||||
from datasette.utils import resolve_routes
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def routes():
|
||||
ds = Datasette()
|
||||
return ds._routes()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"path,expected",
|
||||
(
|
||||
("/", "IndexView"),
|
||||
("/foo", "DatabaseView"),
|
||||
("/foo.csv", "DatabaseView"),
|
||||
("/foo.json", "DatabaseView"),
|
||||
("/foo.humbug", "DatabaseView"),
|
||||
("/foo/humbug", "TableView"),
|
||||
("/foo/humbug.json", "TableView"),
|
||||
("/foo/humbug.blah", "TableView"),
|
||||
("/foo/humbug/1", "RowView"),
|
||||
("/foo/humbug/1.json", "RowView"),
|
||||
("/-/metadata.json", "JsonDataView"),
|
||||
("/-/metadata", "JsonDataView"),
|
||||
),
|
||||
)
|
||||
def test_routes(routes, path, expected):
|
||||
match, view = resolve_routes(routes, path)
|
||||
if expected is None:
|
||||
assert match is None
|
||||
else:
|
||||
assert view.view_class.__name__ == expected
|
||||
Loading…
Add table
Add a link
Reference in a new issue