Ejemplo n.º 1
0
 def test_dumps_normal(self):
     context = Context(
         name="local-test-default",
         user=User(name="user-default", token="invalid-token"),
         cluster=Cluster(
             name="local-test-server",
             server="http://127.0.0.1:8080/",
             cert_data="invalid-ca",
         ),
     )
     config = KubeConfig(contexts=[context])
     assert "clusters" in config.dumps()
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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")