diff options
author | Erik Olof Gunnar Andersson <eandersson@blizzard.com> | 2022-08-12 20:33:45 -0700 |
---|---|---|
committer | Erik Olof Gunnar Andersson <eandersson@blizzard.com> | 2022-08-13 13:23:52 -0700 |
commit | 3e6157f78fb9dd0a492ef9008024cca549ba3e30 (patch) | |
tree | 818e15109359b567cf21f3e2f0ab2bd03a748836 | |
parent | 63563a50983c85df852654e908963eeb7331e3c8 (diff) | |
download | designate-3e6157f78fb9dd0a492ef9008024cca549ba3e30.tar.gz |
Add basic get backend test
- Removed unused start/stop functions
Change-Id: I38ebf73859498acb0c86a4e1f48e92ce371389b8
-rw-r--r-- | designate/backend/__init__.py | 9 | ||||
-rw-r--r-- | designate/backend/base.py | 6 | ||||
-rw-r--r-- | designate/tests/test_backend/__init__.py | 20 | ||||
-rw-r--r-- | designate/tests/unit/backend/test_base.py | 55 |
4 files changed, 60 insertions, 30 deletions
diff --git a/designate/backend/__init__.py b/designate/backend/__init__.py index a95a7641..668bb56f 100644 --- a/designate/backend/__init__.py +++ b/designate/backend/__init__.py @@ -27,12 +27,13 @@ GOOD_STATUSES = [ def get_backend(target): cls = base.Backend.get_driver(target.type) - msg = "Backend Driver '%s' loaded. Has status of '%s'" \ - % (target.type, cls.__backend_status__) + message = "Backend Driver '%s' loaded. Has status of '%s'" % ( + target.type, cls.__backend_status__ + ) if cls.__backend_status__ in GOOD_STATUSES: - LOG.info(msg) + LOG.info(message) else: - LOG.warning(msg) + LOG.warning(message) return cls(target) diff --git a/designate/backend/base.py b/designate/backend/base.py index 2014b3d4..1904474c 100644 --- a/designate/backend/base.py +++ b/designate/backend/base.py @@ -51,12 +51,6 @@ class Backend(DriverPlugin): self.max_retries = CONF['service:worker'].poll_max_retries self.delay = CONF['service:worker'].poll_delay - def start(self): - LOG.info('Starting %s backend', self.get_canonical_name()) - - def stop(self): - LOG.info('Stopped %s backend', self.get_canonical_name()) - # Core Backend Interface @abc.abstractmethod def create_zone(self, context, zone): diff --git a/designate/tests/test_backend/__init__.py b/designate/tests/test_backend/__init__.py deleted file mode 100644 index 92493e0a..00000000 --- a/designate/tests/test_backend/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2015 Hewlett-Packard Development Company, L.P. -# -# Author: Kiall Mac Innes <kiall@hpe.com> -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -from designate.tests import TestCase - - -class BackendTestCase(TestCase): - pass diff --git a/designate/tests/unit/backend/test_base.py b/designate/tests/unit/backend/test_base.py new file mode 100644 index 00000000..3293334a --- /dev/null +++ b/designate/tests/unit/backend/test_base.py @@ -0,0 +1,55 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from unittest import mock + +import oslotest.base +import stevedore.exception + +from designate import backend +from designate.backend import impl_pdns4 +from designate import context +from designate import objects + + +class BaseBackendTestCase(oslotest.base.BaseTestCase): + def setUp(self): + super(BaseBackendTestCase, self).setUp() + + self.context = mock.Mock() + self.admin_context = mock.Mock() + mock.patch.object( + context.DesignateContext, 'get_admin_context', + return_value=self.admin_context).start() + + self.target = { + 'type': 'pdns4', + 'masters': [ + ], + 'options': [ + ], + } + + def test_get_backend(self): + pool_target = objects.PoolTarget.from_dict(self.target) + self.assertIsInstance( + backend.get_backend(pool_target), + impl_pdns4.PDNS4Backend + ) + + def test_get_backend_does_not_exist(self): + self.target['type'] = 'unknown' + pool_target = objects.PoolTarget.from_dict(self.target) + self.assertRaises( + stevedore.exception.NoMatches, + backend.get_backend, pool_target + ) |