summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Dague <sean@dague.net>2017-01-19 09:18:11 -0500
committerSean Dague <sean@dague.net>2017-01-19 09:18:11 -0500
commit1384ec992db4ea1692e66427dfa56edfe9a75528 (patch)
treedc16d21447d2c7fd5fc2ffb6e0ac95c2f9cbe564
parent20ab477eaeb6ca438fcb78edeb53a54169222ea1 (diff)
add tests for merging lines beyond a=b0.1.4
Notes
Notes (review): Code-Review+2: Sean Dague <sean@dague.net> Workflow+1: Sean Dague <sean@dague.net> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 19 Jan 2017 20:26:00 +0000 Reviewed-on: https://review.openstack.org/422645 Project: openstack/devstack-tools Branch: refs/heads/master
-rw-r--r--devstack/dsconf.py4
-rw-r--r--devstack/tests/test_localconf_merge.py34
2 files changed, 36 insertions, 2 deletions
diff --git a/devstack/dsconf.py b/devstack/dsconf.py
index 253d812..72b8d6d 100644
--- a/devstack/dsconf.py
+++ b/devstack/dsconf.py
@@ -233,11 +233,11 @@ class LocalConf(object):
233 if not os.path.exists(self.fname): 233 if not os.path.exists(self.fname):
234 with open(self.fname, "w+") as writer: 234 with open(self.fname, "w+") as writer:
235 writer.write("[[local|localrc]]\n") 235 writer.write("[[local|localrc]]\n")
236 writer.write("%s\n" % line.lstrip()) 236 writer.write("%s\n" % line.rstrip())
237 return 237 return
238 238
239 def _do_set(writer, no_line): 239 def _do_set(writer, no_line):
240 writer.write("%s\n" % line.lstrip()) 240 writer.write("%s\n" % line.rstrip())
241 self._at_insert_point_local(line, _do_set) 241 self._at_insert_point_local(line, _do_set)
242 242
243 def _at_insert_point(self, group, conf, section, name, func): 243 def _at_insert_point(self, group, conf, section, name, func):
diff --git a/devstack/tests/test_localconf_merge.py b/devstack/tests/test_localconf_merge.py
index a6d9424..d1ad75f 100644
--- a/devstack/tests/test_localconf_merge.py
+++ b/devstack/tests/test_localconf_merge.py
@@ -48,6 +48,13 @@ global_physnet_mtu=1400
48compute = auto 48compute = auto
49""" 49"""
50 50
51LC2 = """
52[[local|localrc]]
53# some other comment
54enable_plugin ironic https://github.com/openstack/ironic
55TEMPEST_PLUGINS+=" /opt/stack/new/ironic"
56"""
57
51RESULT1 = """ 58RESULT1 = """
52[[local|localrc]] 59[[local|localrc]]
53a=5 60a=5
@@ -65,6 +72,21 @@ compute = auto
65compute = auto 72compute = auto
66""" 73"""
67 74
75RESULT2 = """
76[[local|localrc]]
77a=b
78c=d
79f=1
80enable_plugin ironic https://github.com/openstack/ironic
81TEMPEST_PLUGINS+=" /opt/stack/new/ironic"
82[[post-config|$NEUTRON_CONF]]
83[DEFAULT]
84global_physnet_mtu=1450
85[[post-config|$NOVA_CONF]]
86[upgrade_levels]
87compute = auto
88"""
89
68 90
69class TestLcMerge(testtools.TestCase): 91class TestLcMerge(testtools.TestCase):
70 92
@@ -86,3 +108,15 @@ class TestLcMerge(testtools.TestCase):
86 with open(self._path) as f: 108 with open(self._path) as f:
87 content = f.read() 109 content = f.read()
88 self.assertEqual(content, RESULT1) 110 self.assertEqual(content, RESULT1)
111
112 def test_merge_lc2(self):
113 dirname = self.useFixture(fixtures.TempDir()).path
114 lc2 = os.path.join(dirname, "local2.conf")
115 with open(lc2, "w+") as f:
116 f.write(LC2)
117 conf = dsconf.LocalConf(self._path)
118 conf.merge_lc(lc2)
119
120 with open(self._path) as f:
121 content = f.read()
122 self.assertEqual(content, RESULT2)