|
14 | 14 |
|
15 | 15 | import unittest
|
16 | 16 |
|
| 17 | +import yaml |
17 | 18 | from kubernetes import utils, client
|
18 | 19 | from kubernetes.e2e_test import base
|
19 | 20 |
|
@@ -42,6 +43,39 @@ def test_create_apps_deployment_from_yaml(self):
|
42 | 43 | name="nginx-app", namespace="default",
|
43 | 44 | body={})
|
44 | 45 |
|
| 46 | + def test_create_apps_deployment_from_yaml_string(self): |
| 47 | + k8s_client = client.api_client.ApiClient(configuration=self.config) |
| 48 | + with open(self.path_prefix + "apps-deployment.yaml") as f: |
| 49 | + yaml_str = f.read() |
| 50 | + |
| 51 | + utils.create_from_yaml( |
| 52 | + k8s_client, yaml_str) |
| 53 | + |
| 54 | + app_api = client.AppsV1beta1Api(k8s_client) |
| 55 | + dep = app_api.read_namespaced_deployment(name="nginx-app", |
| 56 | + namespace="default") |
| 57 | + self.assertIsNotNone(dep) |
| 58 | + app_api.delete_namespaced_deployment( |
| 59 | + name="nginx-app", namespace="default", |
| 60 | + body={}) |
| 61 | + |
| 62 | + def test_create_apps_deployment_from_yaml_obj(self): |
| 63 | + k8s_client = client.api_client.ApiClient(configuration=self.config) |
| 64 | + with open(self.path_prefix + "apps-deployment.yaml") as f: |
| 65 | + yml_obj = yaml.safe_load(f) |
| 66 | + |
| 67 | + utils.create_from_dict( |
| 68 | + k8s_client, yml_obj) |
| 69 | + |
| 70 | + app_api = client.AppsV1beta1Api(k8s_client) |
| 71 | + dep = app_api.read_namespaced_deployment(name="nginx-app", |
| 72 | + namespace="default") |
| 73 | + self.assertIsNotNone(dep) |
| 74 | + app_api.delete_namespaced_deployment( |
| 75 | + name="nginx-app", namespace="default", |
| 76 | + body={}) |
| 77 | + |
| 78 | + |
45 | 79 | def test_create_extensions_deployment_from_yaml(self):
|
46 | 80 | """
|
47 | 81 | Should be able to create an extensions/v1beta1 deployment.
|
|
0 commit comments