diff options
author | Scott Dodson <sdodson@redhat.com> | 2016-08-08 17:19:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-08 17:19:38 -0400 |
commit | 2594364683976584c7654fee480a2ec5501dca59 (patch) | |
tree | dad8a33df9a39b33c965087494cbcad5e959d06b /test/modify_yaml_tests.py | |
parent | 9090df2d6c526d570d33d2315d90d80cc105750b (diff) | |
parent | b3d04f1a54c0109ce38be103ddc7c83f1992c10e (diff) | |
download | openshift-2594364683976584c7654fee480a2ec5501dca59.tar.gz openshift-2594364683976584c7654fee480a2ec5501dca59.tar.bz2 openshift-2594364683976584c7654fee480a2ec5501dca59.tar.xz openshift-2594364683976584c7654fee480a2ec5501dca59.zip |
Merge pull request #2211 from dgoodwin/33-upgrade-playbook
1.3 / 3.3 Upgrades
Diffstat (limited to 'test/modify_yaml_tests.py')
-rw-r--r-- | test/modify_yaml_tests.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/modify_yaml_tests.py b/test/modify_yaml_tests.py new file mode 100644 index 000000000..24cce4855 --- /dev/null +++ b/test/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 + +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']) + |