Added /-/metadata /-/plugins /-/inspect, closes #225

This commit is contained in:
Simon Willison 2018-04-18 22:24:48 -07:00
commit b55809a1e2
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
5 changed files with 111 additions and 14 deletions

View file

@ -29,7 +29,9 @@ def app_client(sql_time_limit_ms=None):
ds.sqlite_functions.append(
('sleep', 1, lambda n: time.sleep(float(n))),
)
yield ds.app().test_client
client = ds.app().test_client
client.ds = ds
yield client
def app_client_longer_time_limit():

View file

@ -3,6 +3,7 @@ from .fixtures import (
app_client_longer_time_limit,
generate_compound_rows,
generate_sortable_rows,
METADATA,
)
import pytest
@ -629,3 +630,30 @@ def test_plugins_dir_plugin(app_client):
gather_request=False
)
assert pytest.approx(328.0839) == response.json['rows'][0][0]
def test_metadata_json(app_client):
response = app_client.get(
"/-/metadata.json",
gather_request=False
)
assert METADATA == response.json
def test_inspect_json(app_client):
response = app_client.get(
"/-/inspect.json",
gather_request=False
)
assert app_client.ds.inspect() == response.json
def test_plugins_json(app_client):
response = app_client.get(
"/-/plugins.json",
gather_request=False
)
# This will include any plugins that have been installed into the
# current virtual environment, so we only check for the presence of
# the one we know will definitely be There
assert {'name': 'my_plugin.py', 'static': False} in response.json