Ejemplo n.º 1
0
    def test_policy_get_all_by_policy_name(self):
        for pid in ['policy1', 'policy2']:
            self.create_policy(id=pid)
            db_api.cluster_policy_attach(self.ctx, self.cluster.id, pid, {})

        results = db_api.cluster_policy_get_by_name(self.ctx, self.cluster.id,
                                                    'test_policy')
        self.assertEqual(2, len(results))

        results = db_api.cluster_policy_get_by_name(self.ctx, self.cluster.id,
                                                    'unknown_policy')
        self.assertEqual(0, len(results))
Ejemplo n.º 2
0
    def test_policy_get_all_by_policy_name_with_filter(self):
        for pid in ['policy1', 'policy2']:
            self.create_policy(id=pid)
            db_api.cluster_policy_attach(self.ctx, self.cluster.id, pid,
                                         {'enabled': True})

        filters = {'enabled': True}
        results = db_api.cluster_policy_get_by_name(self.ctx, self.cluster.id,
                                                    'test_policy',
                                                    filters=filters)
        self.assertEqual(2, len(results))

        filters = {'enabled': False}
        results = db_api.cluster_policy_get_by_name(self.ctx, self.cluster.id,
                                                    'test_policy',
                                                    filters=filters)
        self.assertEqual(0, len(results))