summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorOpenShift Bot <eparis+openshiftbot@redhat.com>2017-04-26 01:23:28 -0500
committerGitHub <noreply@github.com>2017-04-26 01:23:28 -0500
commitc12b00944940cd7f425323e1598a4b7683ddaf75 (patch)
treed1cb21b763579a5c5a2fa5dd0c30078b7383bbe7 /test/unit
parent760bdbc78081d9780d2618c422f31913dd9d38c7 (diff)
parente5f14b515b07bcfa2079c3e68c35fee3e97970c7 (diff)
downloadopenshift-c12b00944940cd7f425323e1598a4b7683ddaf75.tar.gz
openshift-c12b00944940cd7f425323e1598a4b7683ddaf75.tar.bz2
openshift-c12b00944940cd7f425323e1598a4b7683ddaf75.tar.xz
openshift-c12b00944940cd7f425323e1598a4b7683ddaf75.zip
Merge pull request #3816 from sosiouxme/20170328-integration-tests
Merged by openshift-bot
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/modify_yaml_tests.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/unit/modify_yaml_tests.py b/test/unit/modify_yaml_tests.py
new file mode 100644
index 000000000..65b2db44c
--- /dev/null
+++ b/test/unit/modify_yaml_tests.py
@@ -0,0 +1,37 @@
+""" Tests for the modify_yaml Ansible module. """
+# pylint: disable=missing-docstring,invalid-name
+
+import os
+import sys
+import unittest
+
+sys.path = [os.path.abspath(os.path.dirname(__file__) + "/../../library/")] + sys.path
+
+# pylint: disable=import-error
+from modify_yaml import set_key # noqa: E402
+
+
+class ModifyYamlTests(unittest.TestCase):
+
+ def test_simple_nested_value(self):
+ cfg = {"section": {"a": 1, "b": 2}}
+ changes = set_key(cfg, 'section.c', 3)
+ self.assertEquals(1, len(changes))
+ self.assertEquals(3, cfg['section']['c'])
+
+ # Tests a previous bug where property would land in section above where it should,
+ # if the destination section did not yet exist:
+ def test_nested_property_in_new_section(self):
+ cfg = {
+ "masterClients": {
+ "externalKubernetesKubeConfig": "",
+ "openshiftLoopbackKubeConfig": "openshift-master.kubeconfig",
+ },
+ }
+
+ yaml_key = 'masterClients.externalKubernetesClientConnectionOverrides.acceptContentTypes'
+ yaml_value = 'application/vnd.kubernetes.protobuf,application/json'
+ set_key(cfg, yaml_key, yaml_value)
+ self.assertEquals(yaml_value, cfg['masterClients']
+ ['externalKubernetesClientConnectionOverrides']
+ ['acceptContentTypes'])