]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
config: add parameter for config load 1293/head
authorKyr Shatskyy <kyrylo.shatskyy@gmail.com>
Mon, 3 Jun 2019 16:26:55 +0000 (18:26 +0200)
committerKyr Shatskyy <kyrylo.shatskyy@gmail.com>
Mon, 3 Jun 2019 16:34:06 +0000 (18:34 +0200)
This patch makes it possible to load config file directly
from the given path or data object, for testing purposes
and allows to remove silly notification about missing
teuthology.yaml file.

Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@gmail.com>
teuthology/config.py
teuthology/provision/cloud/test/test_openstack.py

index 16b698746a9ae840d5d1fc1b47fe9bf76dfb9428..2144db0a949973c48b3f4943b99771723c00cd6e 100644 (file)
@@ -29,7 +29,13 @@ class YamlConfig(collections.MutableMapping):
         else:
             self._conf = dict()
 
-    def load(self):
+    def load(self, conf=None):
+        if conf:
+            if isinstance(conf, dict):
+                self._conf = conf
+            else:
+                self._conf = yaml.safe_load(conf)
+            return
         if os.path.exists(self.yaml_path):
             self._conf = yaml.safe_load(file(self.yaml_path))
         else:
index cc6afd4952937b0f22c2f97b0d9f4ddd56cd9f2d..bd51667667d464c74f66a49ad2cce35c82c8ff23 100644 (file)
@@ -66,9 +66,8 @@ def get_fake_obj(mock_args=None, attributes=None):
 
 
 class TestOpenStackBase(object):
-    def setup(self):
-        config.load()
-        config.libcloud = deepcopy(test_config)
+    def setup(self, conf=dict(), test_config=test_config):
+        config.load(conf or dict(libcloud=deepcopy(test_config)))
         self.start_patchers()
 
     def start_patchers(self):