Skip to content

Commit

Permalink
One more Druid test (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Apr 21, 2016
1 parent b01d378 commit f1e10d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion caravel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ def query( # druid
}],
}
client.groupby(**qry)
query_str += json.dumps(client.query_dict, indent=2)
query_str += json.dumps(qry, indent=2)
df = client.export_pandas()
if df is None or df.size == 0:
raise Exception("No data was returned.")
Expand Down
17 changes: 15 additions & 2 deletions tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ def test_client(self, PyDruid):
instance.time_boundary.return_value = [
{'result': {'maxTime': '2016-01-01'}}]
instance.segment_metadata.return_value = SEGMENT_METADATA
instance.groupby = GB_RESULT_SET

cluster = (
db.session
Expand All @@ -216,9 +215,23 @@ def test_client(self, PyDruid):
db.session.add(cluster)
cluster.get_datasources = Mock(return_value=['test_datasource'])
cluster.refresh_datasources()
datasource_id = cluster.datasources[0].id
db.session.commit()

self.client.get('/caravel/explore/druid/1/')
resp = self.client.get('/caravel/explore/druid/{}/'.format(datasource_id))
assert "[test_cluster].[test_datasource]" in resp.data.decode('utf-8')

nres = [
list(v['event'].items()) + [('timestamp', v['timestamp'])]
for v in GB_RESULT_SET]
nres = [dict(v) for v in nres]
import pandas as pd
df = pd.DataFrame(nres)
instance.export_pandas.return_value = df
resp = self.client.get('/caravel/explore/druid/1/?viz_type=table&granularity=one+day&druid_time_origin=&since=7+days+ago&until=now&row_limit=5000&include_search=false&metrics=count&flt_col_0=dim1&flt_op_0=in&flt_eq_0=&slice_id=&slice_name=&collapsed_fieldsets=&action=&datasource_name=test_datasource&datasource_id=1&datasource_type=druid&previous_viz_type=table&json=true&force=true')
print('-'*300)
print(resp.data.decode('utf-8'))
assert "Canada" in resp.data.decode('utf-8')


if __name__ == '__main__':
Expand Down

0 comments on commit f1e10d8

Please sign in to comment.