Beispiel #1
0
    def test_namespaces_managed(self) -> None:
        expected = [
            sut.StateSpec(
                type="current",
                oc="stuff",
                cluster="cs1",
                namespace="ns1",
                resource="Template",
                resource_names=["tp1", "tp2"],
            ),
            sut.StateSpec(
                type="desired",
                oc="stuff",
                cluster="cs1",
                namespace="ns1",
                resource={
                    "provider": "resource",
                    "path": "/some/path.yml"
                },
                parent=self.namespaces[0],
            ),
        ]

        rs = sut.init_specs_to_fetch(
            self.resource_inventory,
            self.oc_map,
            namespaces=self.namespaces,
        )
        self.assert_specs_match(rs, expected)
Beispiel #2
0
 def test_namespaces_no_managedresourcenames(self) -> None:
     self.namespaces[0]["managedResourceNames"] = None
     self.namespaces[0]["managedResourceTypeOverrides"] = None
     self.maxDiff = None
     expected = [
         sut.StateSpec(
             type="current",
             oc="stuff",
             cluster="cs1",
             namespace="ns1",
             parent=None,
             resource="Template",
             resource_names=None,
             resource_type_override=None,
         ),
         sut.StateSpec(
             type="desired",
             oc="stuff",
             cluster="cs1",
             namespace="ns1",
             resource={
                 "provider": "resource",
                 "path": "/some/path.yml"
             },
             parent=self.namespaces[0],
         ),
     ]
     rs = sut.init_specs_to_fetch(
         self.resource_inventory,
         self.oc_map,
         namespaces=self.namespaces,
     )
     self.assert_specs_match(rs, expected)
    def test_namespaces_managed_with_overrides(self) -> None:
        self.namespaces[0]['managedResourceTypeOverrides'] = [{
            "resource":
            "Template",
            "override":
            "something.template"
        }]
        expected = [
            sut.StateSpec(
                type="current",
                oc="stuff",
                cluster="cs1",
                namespace="ns1",
                resource="Template",
                resource_names=["tp1", "tp2"],
                resource_type_override="something.template",
            ),
            sut.StateSpec(type="desired",
                          oc="stuff",
                          cluster="cs1",
                          namespace="ns1",
                          resource={
                              "provider": "resource",
                              "path": "/some/path.yml"
                          },
                          parent=self.namespaces[0])
        ]
        rs = sut.init_specs_to_fetch(
            self.resource_inventory,
            self.oc_map,
            namespaces=self.namespaces,
        )

        self.assert_specs_match(rs, expected)
Beispiel #4
0
    def test_namespaces_override_managed_type(self) -> None:
        self.namespaces[0]["managedResourceTypeOverrides"] = [{
            "resource":
            "Project",
            "override":
            "wonderful.project",
        }]

        expected = [
            sut.StateSpec(
                type="current",
                oc="stuff",
                cluster="cs1",
                namespace="ns1",
                parent=None,
                resource="LimitRanges",
                resource_names=None,
                resource_type_override=None,
            ),
            sut.StateSpec(
                type="desired",
                oc="stuff",
                cluster="cs1",
                namespace="ns1",
                resource={
                    "provider": "resource",
                    "path": "/some/path.yml"
                },
                parent=self.namespaces[0],
            ),
        ]

        self.maxDiff = None
        self.mock_callable(
            self.resource_inventory, "initialize_resource_type").for_call(
                "cs1", "ns1",
                "LimitRanges").to_return_value(None).and_assert_called_once()
        rs = sut.init_specs_to_fetch(
            self.resource_inventory,
            oc_map=self.oc_map,
            namespaces=self.namespaces,
            override_managed_types=["LimitRanges"],
        )
        self.assert_specs_match(rs, expected)