summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Dague <sean@dague.net>2017-01-16 12:12:28 -0500
committerSean Dague <sean@dague.net>2017-01-16 12:12:28 -0500
commitedd7cc1bcc14980594ee7a7be80bff5f193c68b2 (patch)
treeb519e4a0dbef870d2c49cc5536dcbeddad5678e3
parente7636a77143b5f03611011e9dd2e367376d80b55 (diff)
tests for merging with existing ini files
-rw-r--r--devstack/tests/test_localconf_extract.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/devstack/tests/test_localconf_extract.py b/devstack/tests/test_localconf_extract.py
index 2a5f767..499a381 100644
--- a/devstack/tests/test_localconf_extract.py
+++ b/devstack/tests/test_localconf_extract.py
@@ -44,6 +44,25 @@ NEUTRON = """[DEFAULT]
44global_physnet_mtu = 1450 44global_physnet_mtu = 1450
45""" 45"""
46 46
47NEUTRON_BASE = """[DEFAULT]
48api_workers = 2
49"""
50
51NEUTRON_BASE_RES = """[DEFAULT]
52global_physnet_mtu = 1450
53api_workers = 2
54"""
55
56NEUTRON_BASE2 = """[DEFAULT]
57api_workers = 2
58global_physnet_mtu = 1400
59"""
60
61NEUTRON_BASE2_RES = """[DEFAULT]
62api_workers = 2
63global_physnet_mtu = 1450
64"""
65
47 66
48class TestLcExtract(testtools.TestCase): 67class TestLcExtract(testtools.TestCase):
49 68
@@ -69,3 +88,29 @@ class TestLcExtract(testtools.TestCase):
69 with open(nova) as f: 88 with open(nova) as f:
70 content = f.read() 89 content = f.read()
71 self.assertEqual(content, NOVA) 90 self.assertEqual(content, NOVA)
91
92 def test_extract_neutron_merge_add(self):
93 dirname = self.useFixture(fixtures.TempDir()).path
94 neutron = os.path.join(dirname, "neutron.conf")
95 with open(neutron, "w+") as f:
96 f.write(NEUTRON_BASE)
97
98 conf = dsconf.LocalConf(self._path)
99 conf.extract("post-config", "$NEUTRON_CONF", neutron)
100
101 with open(neutron) as f:
102 content = f.read()
103 self.assertEqual(content, NEUTRON_BASE_RES)
104
105 def test_extract_neutron_merge_set(self):
106 dirname = self.useFixture(fixtures.TempDir()).path
107 neutron = os.path.join(dirname, "neutron.conf")
108 with open(neutron, "w+") as f:
109 f.write(NEUTRON_BASE2)
110
111 conf = dsconf.LocalConf(self._path)
112 conf.extract("post-config", "$NEUTRON_CONF", neutron)
113
114 with open(neutron) as f:
115 content = f.read()
116 self.assertEqual(content, NEUTRON_BASE2_RES)