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
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):
"""
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,
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"})