mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Better mechanism for handling errors; 404s for missing table/database
New error mechanism closes #193 404s for missing tables/databesse closes #184 Makes pull request #202 unnecessary.
This commit is contained in:
parent
ad6142b67c
commit
9f28bbe43d
6 changed files with 101 additions and 42 deletions
|
|
@ -208,6 +208,17 @@ def test_table_json(app_client):
|
|||
}]
|
||||
|
||||
|
||||
def test_table_not_exists_json(app_client):
|
||||
assert {
|
||||
'ok': False,
|
||||
'error': 'Table not found: blah',
|
||||
'status': 404,
|
||||
'title': None,
|
||||
} == app_client.get(
|
||||
'/test_tables/blah.json', gather_request=False
|
||||
).json
|
||||
|
||||
|
||||
def test_jsono_redirects_to_shape_objects(app_client):
|
||||
response_1 = app_client.get(
|
||||
'/test_tables/simple_primary_key.jsono',
|
||||
|
|
|
|||
|
|
@ -210,6 +210,12 @@ def test_row_html_simple_primary_key(app_client):
|
|||
] == [[str(td) for td in tr.select('td')] for tr in table.select('tbody tr')]
|
||||
|
||||
|
||||
def test_table_not_exists(app_client):
|
||||
assert 'Table not found: blah' in app_client.get(
|
||||
'/test_tables/blah', gather_request=False
|
||||
).body.decode('utf8')
|
||||
|
||||
|
||||
def test_table_html_no_primary_key(app_client):
|
||||
response = app_client.get('/test_tables/no_primary_key', gather_request=False)
|
||||
table = Soup(response.body, 'html.parser').find('table')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue