Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreythewang committed Apr 18, 2018
1 parent 1d92637 commit d2b3e65
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/dashboard_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit d2b3e65

Please sign in to comment.