Merge "Simplified backend unit tests"
This commit is contained in:
commit
63563a5098
|
@ -11,6 +11,7 @@
|
|||
# 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 dns
|
||||
|
@ -18,31 +19,42 @@ import dns.query
|
|||
import dns.rdataclass
|
||||
import dns.rdatatype
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as cfg_fixture
|
||||
import oslotest.base
|
||||
|
||||
import designate.backend.agent as agent
|
||||
import designate.backend.private_codes as pcodes
|
||||
from designate import context
|
||||
from designate import dnsutils
|
||||
from designate import exceptions
|
||||
from designate import objects
|
||||
from designate import tests
|
||||
from designate.tests.unit import RoObject
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
class AgentBackendTestCase(tests.TestCase):
|
||||
|
||||
class AgentBackendTestCase(oslotest.base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(AgentBackendTestCase, self).setUp()
|
||||
self.CONF.set_override('poll_timeout', 1, 'service:worker')
|
||||
self.CONF.set_override('poll_retry_interval', 4,
|
||||
'service:worker')
|
||||
self.CONF.set_override('poll_max_retries', 5, 'service:worker')
|
||||
self.CONF.set_override('poll_delay', 6, 'service:worker')
|
||||
self.useFixture(cfg_fixture.Config(CONF))
|
||||
|
||||
self.context = mock.Mock()
|
||||
self.admin_context = mock.Mock()
|
||||
mock.patch.object(
|
||||
context.DesignateContext, 'get_admin_context',
|
||||
return_value=self.admin_context).start()
|
||||
|
||||
CONF.set_override('poll_timeout', 1, 'service:worker')
|
||||
CONF.set_override('poll_retry_interval', 4, 'service:worker')
|
||||
CONF.set_override('poll_max_retries', 5, 'service:worker')
|
||||
CONF.set_override('poll_delay', 6, 'service:worker')
|
||||
|
||||
self.context = self.get_context()
|
||||
self.zone = objects.Zone(
|
||||
id='e2bed4dc-9d01-11e4-89d3-123b93f75cba',
|
||||
name='example.com.',
|
||||
email='example@example.com',
|
||||
)
|
||||
|
||||
self.target = {
|
||||
'id': '4588652b-50e7-46b9-b688-a9bad40a873e',
|
||||
'type': 'agent',
|
||||
|
|
|
@ -17,24 +17,30 @@
|
|||
import json
|
||||
from unittest import mock
|
||||
|
||||
import oslotest.base
|
||||
import requests
|
||||
|
||||
from designate.backend import impl_akamai_v2 as akamai
|
||||
from designate import context
|
||||
from designate import exceptions
|
||||
from designate import objects
|
||||
import designate.tests
|
||||
from designate.tests import fixtures
|
||||
|
||||
|
||||
class AkamaiBackendTestCase(designate.tests.TestCase):
|
||||
class AkamaiBackendTestCase(oslotest.base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(AkamaiBackendTestCase, self).setUp()
|
||||
|
||||
self.admin_context = mock.Mock()
|
||||
mock.patch.object(
|
||||
context.DesignateContext, 'get_admin_context',
|
||||
return_value=self.admin_context).start()
|
||||
|
||||
self.zone = objects.Zone(
|
||||
id='cca7908b-dad4-4c50-adba-fb67d4c556e8',
|
||||
name='example.com.',
|
||||
email='example@example.com'
|
||||
)
|
||||
|
||||
self.target = {
|
||||
'id': '4588652b-50e7-46b9-b688-a9bad40a873e',
|
||||
'type': 'akamai_v2',
|
||||
|
|
|
@ -11,27 +11,34 @@
|
|||
# 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
|
||||
|
||||
from designate.backend import impl_bind9
|
||||
from designate import context
|
||||
from designate import exceptions
|
||||
from designate import objects
|
||||
import designate.tests
|
||||
from designate.tests import fixtures
|
||||
from designate import utils
|
||||
|
||||
import subprocess
|
||||
|
||||
|
||||
class Bind9BackendTestCase(designate.tests.TestCase):
|
||||
class Bind9BackendTestCase(oslotest.base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(Bind9BackendTestCase, self).setUp()
|
||||
self.admin_context = mock.Mock()
|
||||
mock.patch.object(
|
||||
context.DesignateContext, 'get_admin_context',
|
||||
return_value=self.admin_context).start()
|
||||
|
||||
self.zone = objects.Zone(
|
||||
id='cca7908b-dad4-4c50-adba-fb67d4c556e8',
|
||||
name='example.com.',
|
||||
email='example@example.com'
|
||||
)
|
||||
|
||||
self.target = {
|
||||
'id': '4588652b-50e7-46b9-b688-a9bad40a873e',
|
||||
'type': 'bind9',
|
||||
|
|
|
@ -13,32 +13,38 @@
|
|||
# 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.mock import NonCallableMagicMock
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from designateclient import exceptions
|
||||
from designateclient.v2 import client
|
||||
from oslo_log import log as logging
|
||||
import oslotest.base
|
||||
|
||||
from designate.backend import impl_designate
|
||||
from designate import context
|
||||
from designate import objects
|
||||
import designate.tests
|
||||
from designate.tests import fixtures
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DesignateBackendTestCase(designate.tests.TestCase):
|
||||
class DesignateBackendTestCase(oslotest.base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(DesignateBackendTestCase, self).setUp()
|
||||
self.stdlog = fixtures.StandardLogging()
|
||||
self.useFixture(self.stdlog)
|
||||
|
||||
self.admin_context = mock.Mock()
|
||||
mock.patch.object(
|
||||
context.DesignateContext, 'get_admin_context',
|
||||
return_value=self.admin_context).start()
|
||||
|
||||
self.zone = objects.Zone(
|
||||
id='e2bed4dc-9d01-11e4-89d3-123b93f75cba',
|
||||
name='example.com.',
|
||||
email='example@example.com',
|
||||
)
|
||||
|
||||
self.target = {
|
||||
'id': '4588652b-50e7-46b9-b688-a9bad40a873e',
|
||||
'type': 'designate',
|
||||
|
@ -61,8 +67,8 @@ class DesignateBackendTestCase(designate.tests.TestCase):
|
|||
)
|
||||
|
||||
# Mock client
|
||||
self.client = NonCallableMagicMock()
|
||||
zones = NonCallableMagicMock(spec_set=['create', 'delete'])
|
||||
self.client = mock.NonCallableMagicMock()
|
||||
zones = mock.NonCallableMagicMock(spec_set=['create', 'delete'])
|
||||
|
||||
self.client.configure_mock(zones=zones)
|
||||
|
||||
|
|
|
@ -13,11 +13,15 @@
|
|||
# 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 requests_mock
|
||||
|
||||
from designate.backend import impl_dynect
|
||||
from designate import context
|
||||
from designate import objects
|
||||
import designate.tests
|
||||
|
||||
MASTERS = ["10.0.0.1"]
|
||||
CONTACT = 'jdoe@myco.biz'
|
||||
|
@ -110,18 +114,22 @@ ACTIVATE_SUCCESS = {
|
|||
}
|
||||
|
||||
|
||||
class DynECTTestsCase(designate.tests.TestCase):
|
||||
class DynECTTestsCase(oslotest.base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(DynECTTestsCase, 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.base_address = 'https://api.dynect.net:443/REST'
|
||||
self.context = self.get_context()
|
||||
self.zone = objects.Zone(
|
||||
id='e2bed4dc-9d01-11e4-89d3-123b93f75cba',
|
||||
name='example.com.',
|
||||
email='example@example.com',
|
||||
)
|
||||
|
||||
self.target = {
|
||||
'id': '4588652b-50e7-46b9-b688-a9bad40a873e',
|
||||
'type': 'dyndns',
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
# 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
|
||||
|
||||
from designate.backend import impl_fake
|
||||
from designate import context
|
||||
from designate import objects
|
||||
from designate.tests import fixtures
|
||||
|
||||
|
||||
class FakeBackendTestCase(oslotest.base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(FakeBackendTestCase, self).setUp()
|
||||
self.stdlog = fixtures.StandardLogging()
|
||||
self.useFixture(self.stdlog)
|
||||
|
||||
self.admin_context = mock.Mock()
|
||||
mock.patch.object(
|
||||
context.DesignateContext, 'get_admin_context',
|
||||
return_value=self.admin_context).start()
|
||||
|
||||
self.zone = objects.Zone(
|
||||
id='cca7908b-dad4-4c50-adba-fb67d4c556e8',
|
||||
name='example.test.',
|
||||
email='example@example.test'
|
||||
)
|
||||
self.target = {
|
||||
'id': '4588652b-50e7-46b9-b688-a9bad40a873e',
|
||||
'type': 'fake',
|
||||
'masters': [
|
||||
{'host': '192.168.1.1', 'port': 53},
|
||||
{'host': '192.168.1.2', 'port': 35}
|
||||
],
|
||||
'options': [
|
||||
],
|
||||
}
|
||||
|
||||
self.backend = impl_fake.FakeBackend(
|
||||
objects.PoolTarget.from_dict(self.target)
|
||||
)
|
||||
|
||||
def test_create_zone(self):
|
||||
self.backend.create_zone(self.admin_context, self.zone)
|
||||
|
||||
self.assertIn(
|
||||
"Create Zone <Zone id:'cca7908b-dad4-4c50-adba-fb67d4c556e8' "
|
||||
"type:'None' name:'example.test.' pool_id:'None' serial:'None' "
|
||||
"action:'None' status:'None'>",
|
||||
self.stdlog.logger.output
|
||||
)
|
||||
|
||||
def test_delete_zone(self):
|
||||
self.backend.delete_zone(self.admin_context, self.zone)
|
||||
|
||||
self.assertIn(
|
||||
"Delete Zone <Zone id:'cca7908b-dad4-4c50-adba-fb67d4c556e8' "
|
||||
"type:'None' name:'example.test.' pool_id:'None' serial:'None' "
|
||||
"action:'None' status:'None'>",
|
||||
self.stdlog.logger.output
|
||||
)
|
|
@ -12,27 +12,35 @@
|
|||
# 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 requests_mock
|
||||
|
||||
from designate.backend import impl_infoblox
|
||||
from designate.backend.impl_infoblox import ibexceptions
|
||||
from designate import context
|
||||
from designate import exceptions
|
||||
from designate import objects
|
||||
import designate.tests
|
||||
|
||||
|
||||
class InfobloxBackendTestCase(designate.tests.TestCase):
|
||||
class InfobloxBackendTestCase(oslotest.base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(InfobloxBackendTestCase, self).setUp()
|
||||
self.base_address = 'https://localhost/wapi'
|
||||
|
||||
self.context = self.get_context()
|
||||
self.context = mock.Mock()
|
||||
self.admin_context = mock.Mock()
|
||||
mock.patch.object(
|
||||
context.DesignateContext, 'get_admin_context',
|
||||
return_value=self.admin_context).start()
|
||||
|
||||
self.zone = objects.Zone(
|
||||
id='e2bed4dc-9d01-11e4-89d3-123b93f75cba',
|
||||
name='example.com.',
|
||||
email='example@example.com',
|
||||
)
|
||||
|
||||
self.target = {
|
||||
'id': '4588652b-50e7-46b9-b688-a9bad40a873e',
|
||||
'type': 'infoblox',
|
||||
|
|
|
@ -13,29 +13,37 @@
|
|||
# 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 requests_mock
|
||||
|
||||
from designate.backend import impl_ns1
|
||||
from designate import context
|
||||
from designate import exceptions
|
||||
from designate import objects
|
||||
import designate.tests
|
||||
from designate.tests import fixtures
|
||||
|
||||
|
||||
class NS1BackendTestCase(designate.tests.TestCase):
|
||||
class NS1BackendTestCase(oslotest.base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(NS1BackendTestCase, self).setUp()
|
||||
self.stdlog = fixtures.StandardLogging()
|
||||
self.useFixture(self.stdlog)
|
||||
|
||||
self.context = mock.Mock()
|
||||
self.admin_context = mock.Mock()
|
||||
mock.patch.object(
|
||||
context.DesignateContext, 'get_admin_context',
|
||||
return_value=self.admin_context).start()
|
||||
|
||||
self.api_address = 'https://192.0.2.3/v1/zones/example.com'
|
||||
self.context = self.get_context()
|
||||
self.zone = objects.Zone(
|
||||
id='e2bed4dc-9d01-11e4-89d3-123b93f75cba',
|
||||
name='example.com.',
|
||||
email='example@example.com',
|
||||
)
|
||||
|
||||
self.target = {
|
||||
'id': '4588652b-50e7-46b9-b688-a9bad40a873e',
|
||||
'type': 'ns1',
|
||||
|
|
|
@ -13,32 +13,38 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import socket
|
||||
import ssl
|
||||
from unittest import mock
|
||||
|
||||
import eventlet
|
||||
import oslotest.base
|
||||
|
||||
from designate.backend import impl_nsd4
|
||||
from designate import context
|
||||
from designate import exceptions
|
||||
from designate import objects
|
||||
import designate.tests
|
||||
|
||||
|
||||
class NSD4BackendTestCase(designate.tests.TestCase):
|
||||
class NSD4BackendTestCase(oslotest.base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(NSD4BackendTestCase, 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()
|
||||
|
||||
keyfile = mock.sentinel.key
|
||||
certfile = mock.sentinel.cert
|
||||
|
||||
self.context = self.get_context()
|
||||
self.zone = objects.Zone(
|
||||
id='e2bed4dc-9d01-11e4-89d3-123b93f75cba',
|
||||
name='example.com.',
|
||||
email='example@example.com',
|
||||
)
|
||||
|
||||
self.port = 6969
|
||||
self.target = {
|
||||
'id': '4588652b-50e7-46b9-b688-a9bad40a873e',
|
||||
|
|
|
@ -9,29 +9,36 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import oslotest.base
|
||||
import requests_mock
|
||||
from unittest import mock
|
||||
|
||||
from designate.backend import impl_pdns4
|
||||
from designate import context
|
||||
from designate import exceptions
|
||||
from designate import objects
|
||||
import designate.tests
|
||||
from designate.tests import fixtures
|
||||
|
||||
|
||||
class PDNS4BackendTestCase(designate.tests.TestCase):
|
||||
class PDNS4BackendTestCase(oslotest.base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(PDNS4BackendTestCase, self).setUp()
|
||||
self.stdlog = fixtures.StandardLogging()
|
||||
self.useFixture(self.stdlog)
|
||||
|
||||
self.context = mock.Mock()
|
||||
self.admin_context = mock.Mock()
|
||||
mock.patch.object(
|
||||
context.DesignateContext, 'get_admin_context',
|
||||
return_value=self.admin_context).start()
|
||||
|
||||
self.base_address = 'http://localhost:8081/api/v1/servers'
|
||||
self.context = self.get_context()
|
||||
self.zone = objects.Zone(
|
||||
id='e2bed4dc-9d01-11e4-89d3-123b93f75cba',
|
||||
name='example.com.',
|
||||
email='example@example.com',
|
||||
)
|
||||
|
||||
self.target = {
|
||||
'id': '4588652b-50e7-46b9-b688-a9bad40a873e',
|
||||
'type': 'pdns4',
|
||||
|
|
Loading…
Reference in New Issue