From 0577f9755ad56ce5205e84d5c9facef4846f317a Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Wed, 23 May 2018 12:22:21 +0200 Subject: [PATCH] Test for custom query --- tests/test_api.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_api.py b/tests/test_api.py index 80c6409..834a65d 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -52,3 +52,22 @@ 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 [ + {'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'] -- 2.39.5