From aef8ad38fb0560f69825792a9843a76e1c6eac3c Mon Sep 17 00:00:00 2001 From: John Bodley Date: Tue, 6 Mar 2018 12:09:10 -0800 Subject: [PATCH] [bugfix] Fixing regression from #4500 --- 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 3595ebf767fa0..9225e5da8f65b 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()