def test_valid_yaml_invalid_resource(self, context): config = KubeConfig(contexts=[context]) with config.as_tempfile() as fname: client = KubectlClusterClient(KUBECTL_BIN, kubeconfig=fname) tmpl = textwrap.dedent(''' - invalid - valid - resource ''') with pytest.raises(KubectlExecutionError): client.apply(tmpl) with pytest.raises(KubectlExecutionError): client.delete(tmpl)
def test_normal(self, context): config = KubeConfig(contexts=[context]) with config.as_tempfile() as fname: client = KubectlClusterClient(KUBECTL_BIN, kubeconfig=fname) tmpl = textwrap.dedent(''' apiVersion: v1 data: hello: world kind: ConfigMap metadata: creationTimestamp: null name: bcs-unitest-c1 ''') client.apply(tmpl) client.delete(tmpl)
def test_invalid_format(self, context): config = KubeConfig(contexts=[context]) with config.as_tempfile() as fname: client = KubectlClusterClient(KUBECTL_BIN, kubeconfig=fname) with pytest.raises(KubectlExecutionError): client.apply("invalid_template")