mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[IMP] runbot: allow specifying section for config option
When adding config option, allow to specify it's section (default to odoo standard 'options' section)
This commit is contained in:
parent
6e1fc61781
commit
f8ef025807
@ -74,9 +74,9 @@ class Command():
|
||||
cmd_chain += [' '.join(final) for final in self.finals if final]
|
||||
return ' ; '.join(cmd_chain)
|
||||
|
||||
def add_config_tuple(self, option, value):
|
||||
def add_config_tuple(self, option, value, section=None):
|
||||
assert '-' not in option
|
||||
self.config_tuples.append((option, value))
|
||||
self.config_tuples.append((option, value, section or 'options'))
|
||||
|
||||
def get_config(self, starting_config=''):
|
||||
""" returns a config file content based on config tuples and
|
||||
@ -84,10 +84,10 @@ class Command():
|
||||
"""
|
||||
config = configparser.ConfigParser()
|
||||
config.read_string(starting_config)
|
||||
if self.config_tuples and not config.has_section('options'):
|
||||
config.add_section('options')
|
||||
for option, value in self.config_tuples:
|
||||
config.set('options', option, value)
|
||||
for option, value, section in self.config_tuples:
|
||||
if not config.has_section(section):
|
||||
config.add_section(section)
|
||||
config.set(section, option, value)
|
||||
res = io.StringIO()
|
||||
config.write(res)
|
||||
res.seek(0)
|
||||
|
@ -27,12 +27,16 @@ class Test_Command(common.TransactionCase):
|
||||
self.assertIn('bar', cmd.cmd)
|
||||
cmd.add_config_tuple('x', 'y')
|
||||
|
||||
cmd.add_config_tuple('yy', 'zz', section='other')
|
||||
|
||||
content = cmd.get_config(starting_config=CONFIG)
|
||||
|
||||
self.assertIn('[options]', content)
|
||||
self.assertIn('foo = bar', content)
|
||||
self.assertIn('a = b', content)
|
||||
self.assertIn('x = y', content)
|
||||
self.assertIn('[other]', content)
|
||||
self.assertIn('yy = zz', content)
|
||||
|
||||
with self.assertRaises(AssertionError):
|
||||
cmd.add_config_tuple('http-interface', '127.0.0.1')
|
||||
|
Loading…
Reference in New Issue
Block a user