From f237b0a63c76ef3a3558b446c61382785d1fe41a Mon Sep 17 00:00:00 2001 From: Erik Olof Gunnar Andersson Date: Mon, 15 Aug 2022 22:28:02 -0700 Subject: Add additional backend tests Change-Id: I5dca5495e1d4510682b6244d2e7ca707308927d8 --- designate/tests/unit/backend/test_base.py | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/designate/tests/unit/backend/test_base.py b/designate/tests/unit/backend/test_base.py index 3293334a..45b58e0b 100644 --- a/designate/tests/unit/backend/test_base.py +++ b/designate/tests/unit/backend/test_base.py @@ -16,14 +16,18 @@ import oslotest.base import stevedore.exception from designate import backend +from designate.backend import base from designate.backend import impl_pdns4 from designate import context from designate import objects +from designate.tests import fixtures class BaseBackendTestCase(oslotest.base.BaseTestCase): def setUp(self): super(BaseBackendTestCase, self).setUp() + self.stdlog = fixtures.StandardLogging() + self.useFixture(self.stdlog) self.context = mock.Mock() self.admin_context = mock.Mock() @@ -39,6 +43,40 @@ class BaseBackendTestCase(oslotest.base.BaseTestCase): ], } + @mock.patch.object(base.Backend, 'get_driver') + def test_untested_backend(self, mock_get_driver): + driver = mock.Mock() + driver.__backend_status__ = 'untested' + mock_get_driver.return_value = driver + + self.target['type'] = 'test' + pool_target = objects.PoolTarget.from_dict(self.target) + + backend.get_backend(pool_target) + + self.assertIn('WARNING', self.stdlog.logger.output) + self.assertIn( + "Backend Driver 'test' loaded. Has status of 'untested'", + self.stdlog.logger.output + ) + + @mock.patch.object(base.Backend, 'get_driver') + def test_tested_backend(self, mock_get_driver): + driver = mock.Mock() + driver.__backend_status__ = 'integrated' + mock_get_driver.return_value = driver + + self.target['type'] = 'test' + pool_target = objects.PoolTarget.from_dict(self.target) + + backend.get_backend(pool_target) + + self.assertNotIn('WARNING', self.stdlog.logger.output) + self.assertIn( + "Backend Driver 'test' loaded. Has status of 'integrated'", + self.stdlog.logger.output + ) + def test_get_backend(self): pool_target = objects.PoolTarget.from_dict(self.target) self.assertIsInstance( -- cgit v1.2.1