From f9cd8a6bdf544046916f039cecfbbae645ec2221 Mon Sep 17 00:00:00 2001 From: John Bodley <4567245+john-bodley@users.noreply.github.com> Date: Tue, 6 Mar 2018 21:19:13 -0800 Subject: [PATCH] [bugfix] Fixing regression from #4500 (#4549) (cherry picked from commit ef4e5ecedf2fd5121122b8c4fb27eb259104e057) --- superset/viz.py | 4 ++-- tests/core_tests.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/superset/viz.py b/superset/viz.py index 17d678910c9a9..9bbf53828a593 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -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) @@ -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') diff --git a/tests/core_tests.py b/tests/core_tests.py index 43a3bdfc716c7..e4df8bf05c479 100644 --- a/tests/core_tests.py +++ b/tests/core_tests.py @@ -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') @@ -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()