From edd7cc1bcc14980594ee7a7be80bff5f193c68b2 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Mon, 16 Jan 2017 12:12:28 -0500 Subject: [PATCH] tests for merging with existing ini files --- devstack/tests/test_localconf_extract.py | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) 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] global_physnet_mtu = 1450 """ +NEUTRON_BASE = """[DEFAULT] +api_workers = 2 +""" + +NEUTRON_BASE_RES = """[DEFAULT] +global_physnet_mtu = 1450 +api_workers = 2 +""" + +NEUTRON_BASE2 = """[DEFAULT] +api_workers = 2 +global_physnet_mtu = 1400 +""" + +NEUTRON_BASE2_RES = """[DEFAULT] +api_workers = 2 +global_physnet_mtu = 1450 +""" + class TestLcExtract(testtools.TestCase): @@ -69,3 +88,29 @@ class TestLcExtract(testtools.TestCase): with open(nova) as f: content = f.read() self.assertEqual(content, NOVA) + + def test_extract_neutron_merge_add(self): + dirname = self.useFixture(fixtures.TempDir()).path + neutron = os.path.join(dirname, "neutron.conf") + with open(neutron, "w+") as f: + f.write(NEUTRON_BASE) + + conf = dsconf.LocalConf(self._path) + conf.extract("post-config", "$NEUTRON_CONF", neutron) + + with open(neutron) as f: + content = f.read() + self.assertEqual(content, NEUTRON_BASE_RES) + + def test_extract_neutron_merge_set(self): + dirname = self.useFixture(fixtures.TempDir()).path + neutron = os.path.join(dirname, "neutron.conf") + with open(neutron, "w+") as f: + f.write(NEUTRON_BASE2) + + conf = dsconf.LocalConf(self._path) + conf.extract("post-config", "$NEUTRON_CONF", neutron) + + with open(neutron) as f: + content = f.read() + self.assertEqual(content, NEUTRON_BASE2_RES)