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:
Simon Willison 2018-04-13 11:17:22 -07:00
commit 9f28bbe43d
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
6 changed files with 101 additions and 42 deletions

View file

@ -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',

View file

@ -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')