示例#1
0
    def test_returns_correct_number_of_dashboards(self):
        # Solving https://github.com/getredash/redash/issues/5466

        usr = self.factory.create_user()

        ds1 = self.factory.create_data_source()
        ds2 = self.factory.create_data_source()

        qry1 = self.factory.create_query(data_source=ds1, user=usr)
        qry2 = self.factory.create_query(data_source=ds2, user=usr)

        viz1 = self.factory.create_visualization(query_rel=qry1, )
        viz2 = self.factory.create_visualization(query_rel=qry2, )

        def create_dashboard():
            dash = self.factory.create_dashboard(name="boy howdy", user=usr)
            self.factory.create_widget(dashboard=dash, visualization=viz1)
            self.factory.create_widget(dashboard=dash, visualization=viz2)

            return dash

        d1 = create_dashboard()
        d2 = create_dashboard()

        results = Dashboard.all(self.factory.org, usr.group_ids, usr.id)

        self.assertEqual(2, results.count(),
                         "The incorrect number of dashboards were returned")
示例#2
0
    def test_delete_dashboard(self):
        d = self.factory.create_dashboard()

        rv = self.make_request('delete', '/api/dashboards/{0}'.format(d.slug))
        self.assertEqual(rv.status_code, 200)

        d = Dashboard.get_by_slug_and_org(d.slug, d.org)
        self.assertTrue(d.is_archived)
示例#3
0
    def test_delete_dashboard(self):
        d = self.factory.create_dashboard()

        rv = self.make_request("delete", "/api/dashboards/{0}".format(d.id))
        self.assertEqual(rv.status_code, 200)

        d = Dashboard.get_by_id_and_org(d.id, d.org)
        self.assertTrue(d.is_archived)
示例#4
0
    def test_delete_dashboard(self):
        d = self.factory.create_dashboard()

        rv = self.make_request('delete', '/api/dashboards/{0}'.format(d.slug))
        self.assertEquals(rv.status_code, 200)

        d = Dashboard.get_by_slug_and_org(d.slug, d.org)
        self.assertTrue(d.is_archived)
示例#5
0
    def test_all_tags(self):
        self.create_tagged_dashboard(tags=[u'tag1'])
        self.create_tagged_dashboard(tags=[u'tag1', u'tag2'])
        self.create_tagged_dashboard(tags=[u'tag1', u'tag2', u'tag3'])

        self.assertEqual(
            list(Dashboard.all_tags(self.factory.org, self.factory.user)),
            [(u'tag1', 3), (u'tag2', 2), (u'tag3', 1)]
        )
示例#6
0
    def test_all_tags(self):
        self.create_tagged_dashboard(tags=['tag1'])
        self.create_tagged_dashboard(tags=['tag1', 'tag2'])
        self.create_tagged_dashboard(tags=['tag1', 'tag2', 'tag3'])

        self.assertEqual(
            list(Dashboard.all_tags(self.factory.org, self.factory.user)),
            [('tag1', 3), ('tag2', 2), ('tag3', 1)]
        )
示例#7
0
    def test_returns_only_users_dashboards(self):
        d = self.factory.create_dashboard(user=self.factory.user)
        d2 = self.factory.create_dashboard(user=self.factory.create_user())

        dashboards = Dashboard.by_user(self.factory.user)

        # not using self.assertIn/NotIn because otherwise this fails :O
        self.assertTrue(d in list(dashboards))
        self.assertFalse(d2 in list(dashboards))
示例#8
0
    def test_all_tags(self):
        self.create_tagged_dashboard(tags=["tag1"])
        self.create_tagged_dashboard(tags=["tag1", "tag2"])
        self.create_tagged_dashboard(tags=["tag1", "tag2", "tag3"])

        self.assertEqual(
            list(Dashboard.all_tags(self.factory.org, self.factory.user)),
            [("tag1", 3), ("tag2", 2), ("tag3", 1)],
        )
示例#9
0
    def test_returns_drafts_by_the_user(self):
        d = self.factory.create_dashboard(is_draft=True)
        d2 = self.factory.create_dashboard(is_draft=True,
                                           user=self.factory.create_user())

        dashboards = Dashboard.by_user(self.factory.user)

        # not using self.assertIn/NotIn because otherwise this fails :O
        self.assertTrue(d in dashboards)
        self.assertFalse(d2 in dashboards)