Skip to content

Commit

Permalink
[bugfix] Fixing regression from apache#4500 (apache#4549)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley authored and John Bodley committed Mar 7, 2018
1 parent d995649 commit 7d65550
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def get_payload(self, query_obj=None):

df = payload.get('df')
if self.status != utils.QueryStatus.FAILED:
if df is None or df.empty:
if df is not None and df.empty:
payload['error'] = 'No data'
else:
payload['data'] = self.get_data(df)
Expand Down Expand Up @@ -611,7 +611,7 @@ def query_obj(self):
return None

def get_df(self, query_obj=None):
return pd.DataFrame()
return None

def get_data(self, df):
markup_type = self.form_data.get('markup_type')
Expand Down
11 changes: 10 additions & 1 deletion tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ def test_slice_payload_no_data(self):

data = self.get_json_resp(url)
self.assertEqual(data['status'], utils.QueryStatus.SUCCESS)
assert 'No data' in data['error']
self.assertEqual(data['error'], 'No data')

def test_slice_payload_invalid_query(self):
self.login(username='admin')
Expand All @@ -937,6 +937,15 @@ def test_slice_payload_invalid_query(self):
self.assertEqual(data['status'], utils.QueryStatus.FAILED)
assert 'KeyError' in data['stacktrace']

def test_slice_payload_viz_markdown(self):
self.login(username='admin')
slc = self.get_slice('Title', db.session)

url = slc.get_explore_url(base_url='/superset/explore_json')
data = self.get_json_resp(url)
self.assertEqual(data['status'], None)
self.assertEqual(data['error'], None)


if __name__ == '__main__':
unittest.main()

0 comments on commit 7d65550

Please sign in to comment.