]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Replaced the TeuthologyConfig instance in FakeNamespace with a dict, all the tasks...
authorAndrew Schoen <aschoen@redhat.com>
Wed, 3 Dec 2014 18:35:32 +0000 (12:35 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Sat, 6 Dec 2014 19:46:47 +0000 (13:46 -0600)
Signed-off-by: Andrew Schoen <aschoen@redhat.com>
teuthology/config.py
teuthology/test/test_config.py

index 9623cd385e0e24d797ef04d335ed8d1e099b1640..df1b5c7ca688ebb675eed9b116020217529a42b9 100644 (file)
@@ -148,8 +148,7 @@ class JobConfig(YamlConfig):
 
 class FakeNamespace(YamlConfig):
     """
-    This class is meant to behave like a argparse Namespace with an attached
-    teuthology config at the teuthology_config property.  It mimics the old
+    This class is meant to behave like a argparse Namespace. It mimics the old
     way of doing things with argparse and teuthology.misc.read_config.
 
     We'll use this as a stop-gap as we refactor commands but allow the tasks
@@ -160,10 +159,12 @@ class FakeNamespace(YamlConfig):
             yaml_path = _get_config_path()
         if not config_dict:
             config_dict = dict()
-        # teuthology.misc.read_config attaches the teuthology config
-        # to a teuthology_config attribute of the argparse Namespace
-        config_dict["teuthology_config"] = TeuthologyConfig(yaml_path)
         self._conf = self._clean_config(config_dict)
+        # avoiding circular imports
+        from .misc import read_config
+        # teuthology.misc.read_config attaches the teuthology config
+        # to a teuthology_config key.
+        read_config(self)
 
     def _clean_config(self, config_dict):
         """
index a176179927325a0907920db80fccd86950861467..3393b81a8396ad0dbbcdac162a141343c0018085 100644 (file)
@@ -103,8 +103,9 @@ class TestFakeNamespace(TestYamlConfig):
         self.test_class = config.FakeNamespace
 
     def test_docopt_dict(self):
-        """ Tests if a dict in the format that docopt returns can
-            be parsed correctly.
+        """
+        Tests if a dict in the format that docopt returns can
+        be parsed correctly.
         """
         d = {
             "--verbose": True,
@@ -119,17 +120,16 @@ class TestFakeNamespace(TestYamlConfig):
         assert conf_obj.something == "some_thing"
 
     def test_config(self):
-        """ Tests that a teuthology_config property is automatically added
-            and that defaults are properly used. However, we won't check all
-            the defaults.
+        """
+        Tests that a teuthology_config property is automatically added
+        by misc.read_config.
         """
         conf_obj = self.test_class(dict(foo="bar"))
         assert conf_obj["foo"] == "bar"
         assert conf_obj.foo == "bar"
-        assert conf_obj.teuthology_config.archive_base
-        assert not conf_obj.teuthology_config.automated_scheduling
-        assert conf_obj.teuthology_config.ceph_git_base_url == 'https://github.com/ceph/'
-        assert conf_obj.teuthology_config["ceph_git_base_url"] == 'https://github.com/ceph/'
+        # teuthology_config needs to be a dict because all
+        # of the tasks expect it to be
+        assert isinstance(conf_obj.teuthology_config, dict)
 
     def test_getattr(self):
         conf_obj = self.test_class.from_dict({"foo": "bar"})