Beispiel #1
0
    def test_nonexistent_type(self):
        """Test getting a type that Kubernetes does not have."""

        t = manifest.get_type({
            'apiVersion': 'v1',
            'kind': 'foobar'
        })
        assert t is None
Beispiel #2
0
def load_file(path: str) -> List[object]:
    """ Loads manifest from YAML file and returns kubetest ApiObjects"""
    with open(path, "r") as input_file:
        manifests = yaml.load_all(input_file, Loader=yaml.SafeLoader)
        objs: List[object] = list()
        for manifest in manifests:
            obj_type: Optional[object] = get_type(manifest)
            if obj_type is None:
                LOG.warning("Unable to determine object type for manifest:",
                            manifest)
            else:
                objs.append(new_object(obj_type, manifest))
    return objs
    def test_no_kind(self):
        """Test getting a type when no kind is given."""

        with pytest.raises(ValueError):
            manifest.get_type({'version': 'v1'})
    def test_no_version(self):
        """Test getting a type when no version is given."""

        with pytest.raises(ValueError):
            manifest.get_type({'kind': 'Deployment'})
    def test_ok(self, data, expected):
        """Test getting Kubernetes object types correctly."""

        actual = manifest.get_type(data)
        assert actual == expected
Beispiel #6
0
    def test_nonexistent_type(self):
        """Test getting a type that Kubernetes does not have."""

        t = manifest.get_type({"apiVersion": "v1", "kind": "foobar"})
        assert t is None