コード例 #1
0
    def test_resource_match_kind(self):
        selector = [{
            'kind': 'ConfigMap'
        }]
        is_configmap_match, _ = c.resource_match_selectors(self.configmap_resource, selector)
        is_deployment_match, _ = c.resource_match_selectors(self.deployment_resource, selector)

        self.assertTrue(is_configmap_match)
        self.assertFalse(is_deployment_match)
コード例 #2
0
    def test_resource_match_kind_and_name(self):
        selector = [{
            'name': 'example1',
            'kind': 'ConfigMap',
        }]
        configmap_resource1 = copy.deepcopy(self.configmap_resource)
        configmap_resource1['metadata']['name'] = 'example1'
        configmap_resource2 = copy.deepcopy(self.configmap_resource)
        configmap_resource2['metadata']['name'] = 'example2'
        is_configmap1_match, _ = c.resource_match_selectors(configmap_resource1, selector)
        is_configmap2_match, _ = c.resource_match_selectors(configmap_resource2, selector)

        self.assertTrue(is_configmap1_match)
        self.assertFalse(is_configmap2_match)
コード例 #3
0
    def test_resource_match_selectors_group_all(self):
        deployment_resource = copy.deepcopy(self.deployment_resource)
        is_match, match_metadata = c.resource_match_selectors(deployment_resource, [])

        self.assertTrue(is_match)
        self.assertDictEqual(self.deployment_resource, deployment_resource)
        self.assertDictEqual({
            'group': 'app',
            'version': 'v1',
            'kind': 'Deployment',
            'name': 'example-deployment',
            'namespace': 'example',
        }, match_metadata)
コード例 #4
0
    def test_resource_match_selectors_nogroup_all(self):
        configmap_resource = copy.deepcopy(self.configmap_resource)
        is_match, match_metadata = c.resource_match_selectors(configmap_resource, [])

        self.assertTrue(is_match)
        self.assertDictEqual(self.configmap_resource, configmap_resource)
        self.assertDictEqual({
            'group': '',
            'version': 'v1',
            'kind': 'ConfigMap',
            'name': 'example-configmap',
            'namespace': 'example',
        }, match_metadata)