Esempio n. 1
0
    def test_cluster_count_all_with_admin_context(self):
        values = [
            {
                'project': UUID1
            },
            {
                'project': UUID1
            },
            {
                'project': UUID2
            },
            {
                'project': UUID2
            },
            {
                'project': UUID2
            },
        ]
        [shared.create_cluster(self.ctx, self.profile, **v) for v in values]

        admin_ctx = utils.dummy_context(project='another-project',
                                        is_admin=True)
        self.assertEqual(
            0, db_api.cluster_count_all(admin_ctx, project_safe=True))
        self.assertEqual(
            5, db_api.cluster_count_all(admin_ctx, project_safe=False))
Esempio n. 2
0
    def test_cluster_count_all_with_regular_project(self):
        values = [
            {
                'project': UUID1
            },
            {
                'project': UUID1
            },
            {
                'project': UUID2
            },
            {
                'project': UUID2
            },
            {
                'project': UUID2
            },
        ]
        [shared.create_cluster(self.ctx, self.profile, **v) for v in values]

        self.ctx.project_id = UUID1
        self.assertEqual(2, db_api.cluster_count_all(self.ctx))

        self.ctx.project_id = UUID2
        self.assertEqual(3, db_api.cluster_count_all(self.ctx))
Esempio n. 3
0
    def test_cluster_count_all_show_nested(self):
        cluster1 = shared.create_cluster(self.ctx, self.profile, name='c1')
        shared.create_cluster(self.ctx, self.profile, name='c2',
                              parent=cluster1.id)

        results = db_api.cluster_count_all(self.ctx)
        self.assertEqual(1, results)
        results = db_api.cluster_count_all(self.ctx, show_nested=True)
        self.assertEqual(2, results)
Esempio n. 4
0
    def test_cluster_count_all(self):
        clusters = [shared.create_cluster(self.ctx, self.profile)
                    for i in range(3)]

        cl_db = db_api.cluster_count_all(self.ctx)
        self.assertEqual(3, cl_db)

        db_api.cluster_delete(self.ctx, clusters[0].id)
        cl_db = db_api.cluster_count_all(self.ctx)
        self.assertEqual(2, cl_db)

        db_api.cluster_delete(self.ctx, clusters[1].id)
        cl_db = db_api.cluster_count_all(self.ctx)
        self.assertEqual(1, cl_db)
Esempio n. 5
0
    def test_cluster_count_all(self):
        clusters = [shared.create_cluster(self.ctx, self.profile)
                    for i in range(3)]

        cl_db = db_api.cluster_count_all(self.ctx)
        self.assertEqual(3, cl_db)

        db_api.cluster_delete(self.ctx, clusters[0].id)
        cl_db = db_api.cluster_count_all(self.ctx)
        self.assertEqual(2, cl_db)

        db_api.cluster_delete(self.ctx, clusters[1].id)
        cl_db = db_api.cluster_count_all(self.ctx)
        self.assertEqual(1, cl_db)
Esempio n. 6
0
    def test_cluster_count_all_with_regular_project(self):
        values = [
            {'project': UUID1},
            {'project': UUID1},
            {'project': UUID2},
            {'project': UUID2},
            {'project': UUID2},
        ]
        [shared.create_cluster(self.ctx, self.profile, **v) for v in values]

        self.ctx.project = UUID1
        self.assertEqual(2, db_api.cluster_count_all(self.ctx))

        self.ctx.project = UUID2
        self.assertEqual(3, db_api.cluster_count_all(self.ctx))
Esempio n. 7
0
    def test_cluster_count_all_with_filters(self):
        shared.create_cluster(self.ctx, self.profile, name='foo')
        shared.create_cluster(self.ctx, self.profile, name='bar')
        shared.create_cluster(self.ctx, self.profile, name='bar')
        filters = {'name': 'bar'}

        cl_db = db_api.cluster_count_all(self.ctx, filters=filters)
        self.assertEqual(2, cl_db)
Esempio n. 8
0
    def test_cluster_count_all_with_filters(self):
        shared.create_cluster(self.ctx, self.profile, name='foo')
        shared.create_cluster(self.ctx, self.profile, name='bar')
        shared.create_cluster(self.ctx, self.profile, name='bar')
        filters = {'name': 'bar'}

        cl_db = db_api.cluster_count_all(self.ctx, filters=filters)
        self.assertEqual(2, cl_db)
Esempio n. 9
0
    def test_cluster_count_all_with_project_safe_false(self):
        values = [
            {'project': UUID1},
            {'project': UUID1},
            {'project': UUID2},
            {'project': UUID2},
            {'project': UUID2},
        ]
        [shared.create_cluster(self.ctx, self.profile, **v) for v in values]

        self.assertEqual(5, db_api.cluster_count_all(self.ctx,
                                                     project_safe=False))
Esempio n. 10
0
    def test_cluster_count_all_with_project_safe_false(self):
        values = [
            {'project': UUID1},
            {'project': UUID1},
            {'project': UUID2},
            {'project': UUID2},
            {'project': UUID2},
        ]
        [shared.create_cluster(self.ctx, self.profile, **v) for v in values]

        self.assertEqual(5, db_api.cluster_count_all(self.ctx,
                                                     project_safe=False))
Esempio n. 11
0
    def test_cluster_count_all_with_admin_context(self):
        values = [
            {'project': UUID1},
            {'project': UUID1},
            {'project': UUID2},
            {'project': UUID2},
            {'project': UUID2},
        ]
        [shared.create_cluster(self.ctx, self.profile, **v) for v in values]

        admin_ctx = utils.dummy_context(project='another-project',
                                        is_admin=True)
        self.assertEqual(5, db_api.cluster_count_all(admin_ctx,
                                                     project_safe=True))