summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Johnson <johnsomor@gmail.com>2022-11-23 01:04:40 +0000
committerMichael Johnson <johnsomor@gmail.com>2022-11-23 01:10:47 +0000
commitc3cdc8f2d6063648d42c256f400ea836b5923a7b (patch)
tree7fa1b670f957f4491017880333ff0bf4377bfb94
parent03c729c4791d8fd0feb115fa18b239d993771497 (diff)
downloaddesignate-c3cdc8f2d6063648d42c256f400ea836b5923a7b.tar.gz
Fix configuration leak in unit tests
There was a configuration leak in the agent based bind 9 tests, where if you have a /etc/designate/designate.conf file with settings other than the default the tests would fail. This patch adds a configuration fixture setting override for the two tests to ensure consistent testing. Change-Id: I44dc0499e03431261d5b596206858d94cc4803f9
-rw-r--r--designate/tests/unit/agent/backends/test_bind9.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/designate/tests/unit/agent/backends/test_bind9.py b/designate/tests/unit/agent/backends/test_bind9.py
index f080b565..40f0ea9e 100644
--- a/designate/tests/unit/agent/backends/test_bind9.py
+++ b/designate/tests/unit/agent/backends/test_bind9.py
@@ -95,12 +95,15 @@ class Bind9AgentBackendTestCase(designate.tests.TestCase):
@mock.patch('designate.utils.execute')
@mock.patch.object(dns.zone.Zone, 'to_file')
def test_sync_zone(self, mock_to_file, mock_execute):
+ FAKE_STATE_PATH = '/tmp/fake/state/path'
+ self.CONF.set_override('state_path', FAKE_STATE_PATH)
+
zone = backends.create_dnspy_zone('example.org')
self.backend._sync_zone(zone)
mock_to_file.assert_called_once_with(
- '/var/lib/designate/zones/example.org.zone', relativize=False
+ FAKE_STATE_PATH + '/zones/example.org.zone', relativize=False
)
mock_execute.assert_called_once_with(
@@ -110,16 +113,19 @@ class Bind9AgentBackendTestCase(designate.tests.TestCase):
@mock.patch('designate.utils.execute')
@mock.patch.object(dns.zone.Zone, 'to_file')
def test_sync_zone_with_new_zone(self, mock_to_file, mock_execute):
+ FAKE_STATE_PATH = '/tmp/fake/state/path'
+ self.CONF.set_override('state_path', FAKE_STATE_PATH)
+
zone = backends.create_dnspy_zone('example.org')
self.backend._sync_zone(zone, new_zone_flag=True)
mock_to_file.assert_called_once_with(
- '/var/lib/designate/zones/example.org.zone', relativize=False
+ FAKE_STATE_PATH + '/zones/example.org.zone', relativize=False
)
mock_execute.assert_called_once_with(
'rndc', '-s', '127.0.0.1', '-p', '953', 'addzone',
'example.org { type master; '
- 'file "/var/lib/designate/zones/example.org.zone"; };'
+ 'file "' + FAKE_STATE_PATH + '/zones/example.org.zone"; };'
)