add tests for merging lines beyond a=b
Change-Id: Id2af3b86e19c02fee4058d61e15eb6dd462c6e73
This commit is contained in:
parent
20ab477eae
commit
1384ec992d
|
@ -233,11 +233,11 @@ class LocalConf(object):
|
||||||
if not os.path.exists(self.fname):
|
if not os.path.exists(self.fname):
|
||||||
with open(self.fname, "w+") as writer:
|
with open(self.fname, "w+") as writer:
|
||||||
writer.write("[[local|localrc]]\n")
|
writer.write("[[local|localrc]]\n")
|
||||||
writer.write("%s\n" % line.lstrip())
|
writer.write("%s\n" % line.rstrip())
|
||||||
return
|
return
|
||||||
|
|
||||||
def _do_set(writer, no_line):
|
def _do_set(writer, no_line):
|
||||||
writer.write("%s\n" % line.lstrip())
|
writer.write("%s\n" % line.rstrip())
|
||||||
self._at_insert_point_local(line, _do_set)
|
self._at_insert_point_local(line, _do_set)
|
||||||
|
|
||||||
def _at_insert_point(self, group, conf, section, name, func):
|
def _at_insert_point(self, group, conf, section, name, func):
|
||||||
|
|
|
@ -48,6 +48,13 @@ global_physnet_mtu=1400
|
||||||
compute = auto
|
compute = auto
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
LC2 = """
|
||||||
|
[[local|localrc]]
|
||||||
|
# some other comment
|
||||||
|
enable_plugin ironic https://github.com/openstack/ironic
|
||||||
|
TEMPEST_PLUGINS+=" /opt/stack/new/ironic"
|
||||||
|
"""
|
||||||
|
|
||||||
RESULT1 = """
|
RESULT1 = """
|
||||||
[[local|localrc]]
|
[[local|localrc]]
|
||||||
a=5
|
a=5
|
||||||
|
@ -65,6 +72,21 @@ compute = auto
|
||||||
compute = auto
|
compute = auto
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
RESULT2 = """
|
||||||
|
[[local|localrc]]
|
||||||
|
a=b
|
||||||
|
c=d
|
||||||
|
f=1
|
||||||
|
enable_plugin ironic https://github.com/openstack/ironic
|
||||||
|
TEMPEST_PLUGINS+=" /opt/stack/new/ironic"
|
||||||
|
[[post-config|$NEUTRON_CONF]]
|
||||||
|
[DEFAULT]
|
||||||
|
global_physnet_mtu=1450
|
||||||
|
[[post-config|$NOVA_CONF]]
|
||||||
|
[upgrade_levels]
|
||||||
|
compute = auto
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class TestLcMerge(testtools.TestCase):
|
class TestLcMerge(testtools.TestCase):
|
||||||
|
|
||||||
|
@ -86,3 +108,15 @@ class TestLcMerge(testtools.TestCase):
|
||||||
with open(self._path) as f:
|
with open(self._path) as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
self.assertEqual(content, RESULT1)
|
self.assertEqual(content, RESULT1)
|
||||||
|
|
||||||
|
def test_merge_lc2(self):
|
||||||
|
dirname = self.useFixture(fixtures.TempDir()).path
|
||||||
|
lc2 = os.path.join(dirname, "local2.conf")
|
||||||
|
with open(lc2, "w+") as f:
|
||||||
|
f.write(LC2)
|
||||||
|
conf = dsconf.LocalConf(self._path)
|
||||||
|
conf.merge_lc(lc2)
|
||||||
|
|
||||||
|
with open(self._path) as f:
|
||||||
|
content = f.read()
|
||||||
|
self.assertEqual(content, RESULT2)
|
||||||
|
|
Loading…
Reference in New Issue