Skip to content

Commit

Permalink
Upgrade sqlparse to 0.2.4
Browse files Browse the repository at this point in the history
Add test case for /api/queries/format
  • Loading branch information
ariarijp committed Feb 22, 2018
1 parent c65b637 commit f5d4ca8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ six==1.10.0
SQLAlchemy==1.1.4
SQLAlchemy-Searchable==0.10.6
SQLAlchemy-Utils>=0.29.0
sqlparse==0.1.8
sqlparse==0.2.4
wsgiref==0.1.2
honcho==0.5.0
statsd==2.1.2
Expand Down
16 changes: 16 additions & 0 deletions tests/handlers/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,19 @@ def test_must_have_full_access_to_data_source(self):
rv = self.make_request('post', '/api/queries/{}/fork'.format(query.id))

self.assertEqual(rv.status_code, 403)


class TestFormatSQLQueryAPI(BaseTestCase):
def test_format_sql_query(self):
admin = self.factory.create_admin()
query = 'select a,b,c FROM foobar Where x=1 and y=2;'
expected = """SELECT a,
b,
c
FROM foobar
WHERE x=1
AND y=2;"""

rv = self.make_request('post', '/api/queries/format', user=admin, data={'query': query})

self.assertEqual(rv.json['query'], expected)

0 comments on commit f5d4ca8

Please sign in to comment.