diff options
author | Sean Dague <sean@dague.net> | 2017-01-19 09:18:11 -0500 |
---|---|---|
committer | Sean Dague <sean@dague.net> | 2017-01-19 09:18:11 -0500 |
commit | 1384ec992db4ea1692e66427dfa56edfe9a75528 (patch) | |
tree | dc16d21447d2c7fd5fc2ffb6e0ac95c2f9cbe564 | |
parent | 20ab477eaeb6ca438fcb78edeb53a54169222ea1 (diff) |
add tests for merging lines beyond a=b0.1.4
Change-Id: Id2af3b86e19c02fee4058d61e15eb6dd462c6e73
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.py | 4 | ||||
-rw-r--r-- | devstack/tests/test_localconf_merge.py | 34 |
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 | |||
48 | compute = auto | 48 | compute = auto |
49 | """ | 49 | """ |
50 | 50 | ||
51 | LC2 = """ | ||
52 | [[local|localrc]] | ||
53 | # some other comment | ||
54 | enable_plugin ironic https://github.com/openstack/ironic | ||
55 | TEMPEST_PLUGINS+=" /opt/stack/new/ironic" | ||
56 | """ | ||
57 | |||
51 | RESULT1 = """ | 58 | RESULT1 = """ |
52 | [[local|localrc]] | 59 | [[local|localrc]] |
53 | a=5 | 60 | a=5 |
@@ -65,6 +72,21 @@ compute = auto | |||
65 | compute = auto | 72 | compute = auto |
66 | """ | 73 | """ |
67 | 74 | ||
75 | RESULT2 = """ | ||
76 | [[local|localrc]] | ||
77 | a=b | ||
78 | c=d | ||
79 | f=1 | ||
80 | enable_plugin ironic https://github.com/openstack/ironic | ||
81 | TEMPEST_PLUGINS+=" /opt/stack/new/ironic" | ||
82 | [[post-config|$NEUTRON_CONF]] | ||
83 | [DEFAULT] | ||
84 | global_physnet_mtu=1450 | ||
85 | [[post-config|$NOVA_CONF]] | ||
86 | [upgrade_levels] | ||
87 | compute = auto | ||
88 | """ | ||
89 | |||
68 | 90 | ||
69 | class TestLcMerge(testtools.TestCase): | 91 | class 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) | ||