From d2b3e656a018c84636f64c90fdcc7f335d5f972f Mon Sep 17 00:00:00 2001 From: Jeffrey Wang Date: Thu, 12 Apr 2018 18:00:41 -0400 Subject: [PATCH] Add unit test --- tests/dashboard_tests.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/dashboard_tests.py b/tests/dashboard_tests.py index 3c8ed76e24da4..ad18a7312e698 100644 --- a/tests/dashboard_tests.py +++ b/tests/dashboard_tests.py @@ -295,6 +295,42 @@ def test_only_owners_can_save(self): db.session.commit() self.test_save_dash('alpha') + def test_owners_can_view_empty_dashboard(self): + dash = ( + db.session + .query(models.Dashboard) + .filter_by(slug='empty_dashboard') + .first() + ) + if not dash: + dash = models.Dashboard() + dash.dashboard_title = "Empty Dashboard" + dash.slug = "empty_dashboard" + else: + dash.slices = [] + dash.owners = [] + db.session.merge(dash) + db.session.commit() + + gamma_user = security_manager.find_user('gamma') + self.login(gamma_user.username) + + resp = self.get_resp('/dashboardmodelview/list/') + self.assertNotIn('/superset/dashboard/empty_dashboard/', resp) + + dash = ( + db.session + .query(models.Dashboard) + .filter_by(slug='empty_dashboard') + .first() + ) + dash.owners = [gamma_user] + db.session.merge(dash) + db.session.commit() + + resp = self.get_resp('/dashboardmodelview/list/') + self.assertIn('/superset/dashboard/empty_dashboard/', resp) + if __name__ == '__main__': unittest.main()