Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] Fixing regression from #4500 #4549

Merged
merged 1 commit into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()