X-Git-Url: https://git.jsancho.org/?p=datasette-pytables.git;a=blobdiff_plain;f=tests%2Ftest_api.py;h=85b4bb1c164cfa94866d45c7553f03f09c91f66c;hp=80c64095fae00fb2a22828930506d8b04f0354f2;hb=2ec11308121b4b9c0064ffdde3b583efb95228bc;hpb=06bdd1ac2d8836a2ab8e14074f2435a4c3a595b5 diff --git a/tests/test_api.py b/tests/test_api.py index 80c6409..85b4bb1 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -52,3 +52,23 @@ def test_database_page(app_client): 'fts_table': None, 'foreign_keys': {'incoming': [], 'outgoing': []} }] == data['tables'] + +def test_custom_sql(app_client): + response = app_client.get( + '/test_tables.json?sql=select+identity+from+[/group1/table1]&_shape=objects', + gather_request=False + ) + data = response.json + assert { + 'sql': 'select identity from [/group1/table1]', + 'params': {} + } == data['query'] + assert 50 == len(data['rows']) + assert [ + {'identity': 'This is particle: 0'}, + {'identity': 'This is particle: 1'}, + {'identity': 'This is particle: 2'} + ] == data['rows'][:3] + assert ['identity'] == data['columns'] + assert 'test_tables' == data['database'] + assert data['truncated']