예제 #1
0
파일: config.py 프로젝트: noah8713/rally
    def create(self, conf_path, extra_options=None):
        self.conf.read(os.path.join(os.path.dirname(__file__), "config.ini"))

        for name, method in inspect.getmembers(self, inspect.ismethod):
            if name.startswith("_configure_"):
                method()

        if extra_options:
            utils.add_extra_options(extra_options, self.conf)

        with open(conf_path, "w") as configfile:
            self.conf.write(configfile)

        raw_conf = six.StringIO()
        raw_conf.write("# Some empty values of options will be replaced while "
                       "creating required resources (images, flavors, etc).\n")
        self.conf.write(raw_conf)

        return raw_conf.getvalue()
예제 #2
0
    def test_add_extra_options(self):
        conf = configparser.ConfigParser()
        extra_options = {"section": {"foo": "bar"},
                         "section2": {"option": "value"}}

        conf = utils.add_extra_options(extra_options, conf)

        expected = {"section": ("foo", "bar"), "section2": ("option", "value")}
        for section, option in expected.items():
            result = conf.items(section)
            self.assertIn(option, result)
예제 #3
0
    def test_add_extra_options(self):
        conf = configparser.ConfigParser()
        extra_options = {
            "section": {
                "foo": "bar"
            },
            "section2": {
                "option": "value"
            }
        }

        conf = utils.add_extra_options(extra_options, conf)

        expected = {"section": ("foo", "bar"), "section2": ("option", "value")}
        for section, option in expected.items():
            result = conf.items(section)
            self.assertIn(option, result)