Merge "Use unittest.mock instead of third party mock"
This commit is contained in:
commit
7869cc9df0
@ -19,6 +19,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from __future__ import absolute_import
|
||||
from unittest import mock
|
||||
|
||||
import logging as std_logging
|
||||
import os
|
||||
@ -28,7 +29,6 @@ import tempfile
|
||||
from contextlib import contextmanager
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
import tooz.coordination
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
@ -14,7 +14,8 @@
|
||||
# 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 mock
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_messaging.notify import notifier
|
||||
|
||||
|
@ -13,8 +13,9 @@
|
||||
# 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 patch
|
||||
|
||||
import six
|
||||
from mock import patch
|
||||
import oslo_messaging as messaging
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -13,7 +13,8 @@
|
||||
# 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 mock import patch
|
||||
from unittest.mock import patch
|
||||
|
||||
import oslo_messaging as messaging
|
||||
|
||||
from designate import exceptions
|
||||
|
@ -13,8 +13,9 @@
|
||||
# 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 mock
|
||||
from mock import patch
|
||||
from unittest.mock import patch
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
import oslo_messaging as messaging
|
||||
|
||||
|
@ -9,7 +9,8 @@
|
||||
# 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 mock
|
||||
from unittest import mock
|
||||
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -19,8 +19,8 @@ import datetime
|
||||
import copy
|
||||
import random
|
||||
from collections import namedtuple
|
||||
from unittest import mock
|
||||
|
||||
import mock
|
||||
import testtools
|
||||
from testtools.matchers import GreaterThan
|
||||
from oslo_config import cfg
|
||||
|
@ -13,7 +13,8 @@
|
||||
# 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 mock
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from designate import coordination
|
||||
|
@ -13,9 +13,10 @@
|
||||
# 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 Mock
|
||||
from unittest.mock import patch
|
||||
|
||||
import six
|
||||
from mock import Mock
|
||||
from mock import patch
|
||||
from oslo_config import cfg
|
||||
from stevedore.hook import HookManager
|
||||
from stevedore.extension import Extension
|
||||
|
@ -14,13 +14,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import binascii
|
||||
from unittest import mock
|
||||
|
||||
import dns
|
||||
import dns.rdataclass
|
||||
import dns.rdatatype
|
||||
import dns.resolver
|
||||
import dns.rrset
|
||||
import mock
|
||||
import testtools
|
||||
from oslo_config import cfg
|
||||
|
||||
|
@ -13,13 +13,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import binascii
|
||||
from unittest import mock
|
||||
from unittest.mock import patch
|
||||
|
||||
import dns
|
||||
import dns.message
|
||||
import dns.query
|
||||
import dns.exception
|
||||
import mock
|
||||
from mock import patch
|
||||
|
||||
from designate.tests.test_mdns import MdnsTestCase
|
||||
from designate.mdns import notify
|
||||
|
@ -18,10 +18,10 @@ import binascii
|
||||
import errno
|
||||
import socket
|
||||
import struct
|
||||
from unittest import mock
|
||||
|
||||
import dns
|
||||
import dns.message
|
||||
import mock
|
||||
from oslo_log import log as logging
|
||||
|
||||
from designate.tests.test_mdns import MdnsTestCase
|
||||
|
@ -14,7 +14,8 @@
|
||||
# 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 mock
|
||||
from unittest import mock
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from designate.tests import TestCase
|
||||
|
@ -14,8 +14,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import operator
|
||||
from unittest import mock
|
||||
|
||||
import mock
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.sql import operators
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import math
|
||||
from unittest import mock
|
||||
|
||||
import mock
|
||||
import testtools
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
@ -13,8 +13,9 @@
|
||||
# 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
|
||||
|
||||
from oslo_log import log as logging
|
||||
import mock
|
||||
|
||||
from designate import storage
|
||||
from designate.tests import TestCase
|
||||
|
@ -13,8 +13,9 @@
|
||||
# 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.resolver
|
||||
import mock
|
||||
|
||||
import designate.tests
|
||||
from designate import exceptions
|
||||
|
@ -13,7 +13,8 @@
|
||||
# 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 mock
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
import designate.tests
|
||||
|
@ -13,7 +13,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.
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import designate.tests
|
||||
from designate import exceptions
|
||||
|
@ -13,7 +13,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.
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import designate.tests
|
||||
from designate.backend.agent_backend import impl_gdnsd
|
||||
|
@ -13,8 +13,9 @@
|
||||
# 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 mock
|
||||
from mock import call
|
||||
from unittest.mock import call
|
||||
from unittest import mock
|
||||
|
||||
from oslo_concurrency import processutils
|
||||
|
||||
import designate.tests
|
||||
|
@ -14,7 +14,8 @@
|
||||
# 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 mock
|
||||
from unittest import mock
|
||||
|
||||
from os_win import constants
|
||||
from os_win import exceptions as os_win_exc
|
||||
from os_win import utilsfactory
|
||||
|
@ -14,10 +14,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import binascii
|
||||
from unittest import mock
|
||||
|
||||
import dns
|
||||
import dns.resolver
|
||||
import mock
|
||||
|
||||
import designate
|
||||
import designate.tests
|
||||
|
@ -13,7 +13,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.
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import designate.tests
|
||||
from designate import dnsutils
|
||||
|
@ -13,7 +13,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.
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import designate.tests
|
||||
from designate import exceptions
|
||||
|
@ -13,7 +13,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.
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import designate.tests
|
||||
from designate import exceptions
|
||||
|
@ -13,8 +13,9 @@
|
||||
# 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 fixtures
|
||||
import mock
|
||||
import oslotest.base
|
||||
|
||||
from designate.api import middleware
|
||||
|
@ -11,10 +11,11 @@
|
||||
# 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
|
||||
import dns.rdataclass
|
||||
import dns.rdatatype
|
||||
import mock
|
||||
|
||||
import designate.backend.agent as agent
|
||||
import designate.backend.private_codes as pcodes
|
||||
|
@ -15,7 +15,8 @@
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import requests
|
||||
|
||||
import designate.tests
|
||||
|
@ -11,7 +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.
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import designate.tests
|
||||
from designate import exceptions
|
||||
|
@ -13,9 +13,10 @@
|
||||
# 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 designateclient import exceptions
|
||||
from designateclient.v2 import client
|
||||
from mock import NonCallableMagicMock
|
||||
from oslo_log import log as logging
|
||||
|
||||
import designate.tests
|
||||
|
@ -12,7 +12,8 @@
|
||||
# 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 mock
|
||||
from unittest import mock
|
||||
|
||||
import requests_mock
|
||||
|
||||
import designate.tests
|
||||
|
@ -15,9 +15,9 @@
|
||||
# under the License.
|
||||
import socket
|
||||
import ssl
|
||||
from unittest import mock
|
||||
|
||||
import eventlet
|
||||
import mock
|
||||
|
||||
import designate.tests
|
||||
from designate import exceptions
|
||||
|
@ -9,7 +9,8 @@
|
||||
# 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 mock
|
||||
from unittest import mock
|
||||
|
||||
import requests_mock
|
||||
|
||||
from designate import exceptions
|
||||
|
@ -13,8 +13,9 @@
|
||||
# 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
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as cfg_fixture
|
||||
import oslotest.base
|
||||
|
@ -14,11 +14,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import socket
|
||||
from unittest import mock
|
||||
|
||||
import dns
|
||||
import dns.rdataclass
|
||||
import dns.rdatatype
|
||||
import mock
|
||||
|
||||
import designate.mdns.notify as notify
|
||||
import designate.tests
|
||||
|
@ -13,7 +13,8 @@
|
||||
# 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 mock
|
||||
from unittest import mock
|
||||
|
||||
import oslotest.base
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as cfg_fixture
|
||||
|
@ -13,7 +13,8 @@
|
||||
# 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 mock
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as cfg_fixture
|
||||
import oslotest.base
|
||||
|
@ -14,8 +14,8 @@
|
||||
# under the License.
|
||||
#
|
||||
import time
|
||||
from unittest import mock
|
||||
|
||||
import mock
|
||||
import monascastatsd
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as cfg_fixture
|
||||
|
@ -13,7 +13,8 @@
|
||||
# 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 mock
|
||||
from unittest import mock
|
||||
|
||||
from neutronclient.common import exceptions as neutron_exceptions
|
||||
from neutronclient.v2_0 import client as clientv20
|
||||
from oslo_config import cfg
|
||||
@ -47,7 +48,7 @@ class NeutronNetworkAPITest(oslotest.base.BaseTestCase):
|
||||
def test_get_client(self, mock_client):
|
||||
neutron.get_client(self.context, 'http://localhost:9696')
|
||||
|
||||
kwargs = mock_client.call_args.kwargs
|
||||
_, kwargs = mock_client.call_args
|
||||
|
||||
self.assertIn('endpoint_url', kwargs)
|
||||
self.assertIn('timeout', kwargs)
|
||||
@ -67,14 +68,14 @@ class NeutronNetworkAPITest(oslotest.base.BaseTestCase):
|
||||
|
||||
neutron.get_client(self.context, 'http://localhost:9696')
|
||||
|
||||
kwargs = mock_client.call_args.kwargs
|
||||
_, kwargs = mock_client.call_args
|
||||
|
||||
self.assertIn('token', kwargs)
|
||||
self.assertIn('auth_strategy', kwargs)
|
||||
self.assertNotIn('username', kwargs)
|
||||
|
||||
self.assertEqual('http://localhost:9696', kwargs['endpoint_url'])
|
||||
self.assertEqual(kwargs['token'], self.context.auth_token)
|
||||
self.assertEqual(self.context.auth_token, kwargs['token'])
|
||||
|
||||
@mock.patch.object(clientv20, 'Client')
|
||||
def test_get_client_using_admin(self, mock_client):
|
||||
@ -85,7 +86,7 @@ class NeutronNetworkAPITest(oslotest.base.BaseTestCase):
|
||||
|
||||
neutron.get_client(self.context, 'http://localhost:9696')
|
||||
|
||||
kwargs = mock_client.call_args.kwargs
|
||||
_, kwargs = mock_client.call_args
|
||||
|
||||
self.assertIn('auth_strategy', kwargs)
|
||||
self.assertIn('username', kwargs)
|
||||
|
@ -9,7 +9,8 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.mport threading
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import oslotest.base
|
||||
from oslo_config import cfg
|
||||
|
||||
|
@ -14,9 +14,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import datetime
|
||||
from unittest.mock import Mock
|
||||
|
||||
import oslotest.base
|
||||
from mock import Mock
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import timeutils
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
# under the License.
|
||||
import copy
|
||||
from operator import attrgetter
|
||||
from unittest import mock
|
||||
|
||||
import mock
|
||||
import oslotest.base
|
||||
import testtools
|
||||
from oslo_log import log as logging
|
||||
|
@ -14,8 +14,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import itertools
|
||||
from unittest import mock
|
||||
|
||||
import mock
|
||||
import oslotest.base
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -18,7 +18,8 @@
|
||||
Unit-test Producer service
|
||||
"""
|
||||
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import oslotest.base
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as cfg_fixture
|
||||
|
@ -18,9 +18,9 @@
|
||||
Unit test Producer tasks
|
||||
"""
|
||||
import datetime
|
||||
from unittest import mock
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
import oslotest.base
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as cfg_fixture
|
||||
|
@ -11,7 +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 mock import Mock
|
||||
from unittest.mock import Mock
|
||||
|
||||
from designate import exceptions
|
||||
from designate import objects
|
||||
|
@ -11,8 +11,9 @@
|
||||
# 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 Mock
|
||||
|
||||
import fixtures
|
||||
from mock import Mock
|
||||
|
||||
from designate import exceptions
|
||||
from designate import objects
|
||||
|
@ -10,7 +10,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.mport threading
|
||||
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import oslotest.base
|
||||
from oslo_config import cfg
|
||||
|
||||
|
@ -9,7 +9,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.mport threading
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import designate.tests
|
||||
import designate.rpc
|
||||
|
@ -14,13 +14,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import unittest
|
||||
from unittest import mock
|
||||
from unittest.mock import patch
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
import six
|
||||
import testtools
|
||||
from mock import Mock
|
||||
from mock import patch
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as cfg_fixture
|
||||
from oslo_log import log as logging
|
||||
@ -394,7 +393,7 @@ class CentralServiceTestCase(CentralBasic):
|
||||
central_service._is_valid_recordset_placement_subzone = mock.Mock()
|
||||
central_service._is_valid_ttl = mock.Mock()
|
||||
|
||||
MockRecordSet.obj_get_changes = Mock(return_value={'ttl': 3600})
|
||||
MockRecordSet.obj_get_changes = mock.Mock(return_value={'ttl': 3600})
|
||||
|
||||
central_service._validate_recordset(
|
||||
self.context, Mockzone, MockRecordSet
|
||||
@ -407,11 +406,11 @@ class CentralServiceTestCase(CentralBasic):
|
||||
self.assertTrue(central_service._is_valid_ttl.called)
|
||||
|
||||
def test_create_recordset_in_storage(self):
|
||||
self.service._enforce_recordset_quota = Mock()
|
||||
self.service._enforce_recordset_quota = mock.Mock()
|
||||
self.service._validate_recordset = mock.Mock()
|
||||
|
||||
self.service.storage.create_recordset = Mock(return_value='rs')
|
||||
self.service._update_zone_in_storage = Mock()
|
||||
self.service.storage.create_recordset = mock.Mock(return_value='rs')
|
||||
self.service._update_zone_in_storage = mock.Mock()
|
||||
|
||||
rs, zone = self.service._create_recordset_in_storage(
|
||||
self.context, Mockzone(), MockRecordSet()
|
||||
@ -432,7 +431,7 @@ class CentralServiceTestCase(CentralBasic):
|
||||
central_service.storage.create_recordset = mock.Mock(return_value='rs')
|
||||
central_service._update_zone_in_storage = mock.Mock()
|
||||
|
||||
recordset = Mock()
|
||||
recordset = mock.Mock()
|
||||
recordset.obj_attr_is_set.return_value = True
|
||||
recordset.records = [MockRecord()]
|
||||
|
||||
@ -457,7 +456,7 @@ class CentralServiceTestCase(CentralBasic):
|
||||
# NOTE(thirose): Since this is a race condition we assume that
|
||||
# we will hit it if we try to do the operations in a loop 100 times.
|
||||
for num in range(100):
|
||||
recordset = Mock()
|
||||
recordset = mock.Mock()
|
||||
recordset.name = "b{}".format(num)
|
||||
recordset.obj_attr_is_set.return_value = True
|
||||
recordset.records = [MockRecord()]
|
||||
@ -472,10 +471,10 @@ class CentralServiceTestCase(CentralBasic):
|
||||
def test_create_soa(self):
|
||||
central_service = self.central_service
|
||||
|
||||
central_service._create_recordset_in_storage = Mock(
|
||||
central_service._create_recordset_in_storage = mock.Mock(
|
||||
return_value=(None, None)
|
||||
)
|
||||
central_service._build_soa_record = Mock(
|
||||
central_service._build_soa_record = mock.Mock(
|
||||
return_value='example.org. foo.bar 1 60 5 999 1'
|
||||
)
|
||||
zone = Mockzone()
|
||||
@ -490,9 +489,9 @@ class CentralServiceTestCase(CentralBasic):
|
||||
self.assertTrue(rset.records.objects[0].managed)
|
||||
|
||||
def test_create_zone_in_storage(self):
|
||||
self.service._create_soa = Mock()
|
||||
self.service._create_ns = Mock()
|
||||
self.service.get_zone_ns_records = Mock(
|
||||
self.service._create_soa = mock.Mock()
|
||||
self.service._create_ns = mock.Mock()
|
||||
self.service.get_zone_ns_records = mock.Mock(
|
||||
return_value=[RoObject(hostname='host_foo')]
|
||||
)
|
||||
|
||||
@ -566,33 +565,33 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.service.storage.find_tld = storage_find_tld
|
||||
|
||||
def test_is_valid_zone_name_valid(self):
|
||||
self.service._is_blacklisted_zone_name = Mock()
|
||||
self.service._is_blacklisted_zone_name = mock.Mock()
|
||||
self.service._is_valid_zone_name(self.context, 'valid.org.')
|
||||
|
||||
def test_is_valid_zone_name_invalid(self):
|
||||
self.service._is_blacklisted_zone_name = Mock()
|
||||
self.service._is_blacklisted_zone_name = mock.Mock()
|
||||
with testtools.ExpectedException(exceptions.InvalidZoneName):
|
||||
self.service._is_valid_zone_name(self.context,
|
||||
'example^org.')
|
||||
|
||||
def test_is_valid_zone_name_invalid_2(self):
|
||||
self.service._is_blacklisted_zone_name = Mock()
|
||||
self.service._is_blacklisted_zone_name = mock.Mock()
|
||||
with testtools.ExpectedException(exceptions.InvalidZoneName):
|
||||
self.service._is_valid_zone_name(self.context,
|
||||
'example.tld.')
|
||||
|
||||
def test_is_valid_zone_name_invalid_same_as_tld(self):
|
||||
self.service._is_blacklisted_zone_name = Mock()
|
||||
self.service._is_blacklisted_zone_name = mock.Mock()
|
||||
with testtools.ExpectedException(exceptions.InvalidZoneName):
|
||||
self.service._is_valid_zone_name(self.context, 'com.com.')
|
||||
|
||||
def test_is_valid_zone_name_invalid_tld(self):
|
||||
self.service._is_blacklisted_zone_name = Mock()
|
||||
self.service._is_blacklisted_zone_name = mock.Mock()
|
||||
with testtools.ExpectedException(exceptions.InvalidZoneName):
|
||||
self.service._is_valid_zone_name(self.context, 'tld.')
|
||||
|
||||
def test_is_valid_zone_name_blacklisted(self):
|
||||
self.service._is_blacklisted_zone_name = Mock(
|
||||
self.service._is_blacklisted_zone_name = mock.Mock(
|
||||
side_effect=exceptions.InvalidZoneName)
|
||||
with testtools.ExpectedException(exceptions.InvalidZoneName):
|
||||
self.service._is_valid_zone_name(self.context,
|
||||
@ -710,7 +709,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
|
||||
def test_is_valid_recordset_placement_subzone_2(self):
|
||||
zone = RoObject(name='example.org.', id=CentralZoneTestCase.zone__id)
|
||||
self.service._is_valid_recordset_name = Mock(
|
||||
self.service._is_valid_recordset_name = mock.Mock(
|
||||
side_effect=Exception)
|
||||
self.service.storage.find_zones.return_value = [
|
||||
RoObject(name='foo.example.org.')
|
||||
@ -723,7 +722,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
|
||||
def test_is_valid_recordset_placement_subzone_failing(self):
|
||||
zone = RoObject(name='example.org.', id=CentralZoneTestCase.zone__id)
|
||||
self.service._is_valid_recordset_name = Mock()
|
||||
self.service._is_valid_recordset_name = mock.Mock()
|
||||
self.service.storage.find_zones.return_value = [
|
||||
RoObject(name='foo.example.org.')
|
||||
]
|
||||
@ -750,7 +749,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
def test_is_superzone(self):
|
||||
central_service = self.central_service
|
||||
|
||||
central_service.storage.find_zones = Mock()
|
||||
central_service.storage.find_zones = mock.Mock()
|
||||
central_service._is_superzone(self.context, 'example.org.', '1')
|
||||
_, crit = self.service.storage.find_zones.call_args[0]
|
||||
self.assertEqual({'name': '%.example.org.', 'pool_id': '1'}, crit)
|
||||
@ -762,7 +761,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.service._increment_zone_serial(self.context, zone)
|
||||
|
||||
def test_create_ns(self):
|
||||
self.service._create_recordset_in_storage = Mock(
|
||||
self.service._create_recordset_in_storage = mock.Mock(
|
||||
return_value=(0, 0))
|
||||
self.service._create_ns(
|
||||
self.context,
|
||||
@ -778,7 +777,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertTrue(rset.records[0].managed)
|
||||
|
||||
def test_create_ns_skip(self):
|
||||
self.service._create_recordset_in_storage = Mock()
|
||||
self.service._create_recordset_in_storage = mock.Mock()
|
||||
self.service._create_ns(
|
||||
self.context,
|
||||
RoObject(type='SECONDARY', name='example.org.'),
|
||||
@ -788,9 +787,9 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.service._create_recordset_in_storage.called)
|
||||
|
||||
def test_add_ns_creation(self):
|
||||
self.service._create_ns = Mock()
|
||||
self.service._create_ns = mock.Mock()
|
||||
|
||||
self.service.find_recordsets = Mock(
|
||||
self.service.find_recordsets = mock.Mock(
|
||||
return_value=[]
|
||||
)
|
||||
|
||||
@ -803,12 +802,12 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertTrue(len(records), 1)
|
||||
|
||||
def test_add_ns(self):
|
||||
self.service._update_recordset_in_storage = Mock()
|
||||
self.service._update_recordset_in_storage = mock.Mock()
|
||||
|
||||
recordsets = [
|
||||
RoObject(records=objects.RecordList.from_list([]), managed=True)
|
||||
]
|
||||
self.service.find_recordsets = Mock(
|
||||
self.service.find_recordsets = mock.Mock(
|
||||
return_value=recordsets
|
||||
)
|
||||
|
||||
@ -824,14 +823,14 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual('bar', rset.records[0].data.name)
|
||||
|
||||
def test_add_ns_with_other_ns_rs(self):
|
||||
self.service._update_recordset_in_storage = Mock()
|
||||
self.service._update_recordset_in_storage = mock.Mock()
|
||||
|
||||
recordsets = [
|
||||
RoObject(records=objects.RecordList.from_list([]), managed=True),
|
||||
RoObject(records=objects.RecordList.from_list([]), managed=False)
|
||||
]
|
||||
|
||||
self.service.find_recordsets = Mock(
|
||||
self.service.find_recordsets = mock.Mock(
|
||||
return_value=recordsets
|
||||
)
|
||||
|
||||
@ -847,13 +846,13 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual('bar', rset.records[0].data.name)
|
||||
|
||||
def test_create_zone_no_servers(self):
|
||||
self.service._enforce_zone_quota = Mock()
|
||||
self.service._is_valid_zone_name = Mock()
|
||||
self.service._is_valid_ttl = Mock()
|
||||
self.service._is_subzone = Mock(
|
||||
self.service._enforce_zone_quota = mock.Mock()
|
||||
self.service._is_valid_zone_name = mock.Mock()
|
||||
self.service._is_valid_ttl = mock.Mock()
|
||||
self.service._is_subzone = mock.Mock(
|
||||
return_value=False
|
||||
)
|
||||
self.service._is_superzone = Mock(
|
||||
self.service._is_superzone = mock.Mock(
|
||||
return_value=[]
|
||||
)
|
||||
self.service.storage.get_pool.return_value = RoObject(
|
||||
@ -881,19 +880,19 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.context, z)
|
||||
|
||||
def test_create_zone(self):
|
||||
self.service._enforce_zone_quota = Mock()
|
||||
self.service._create_zone_in_storage = Mock(
|
||||
self.service._enforce_zone_quota = mock.Mock()
|
||||
self.service._create_zone_in_storage = mock.Mock(
|
||||
return_value=objects.Zone(
|
||||
name='example.com.',
|
||||
type='PRIMARY',
|
||||
)
|
||||
)
|
||||
self.service._is_valid_zone_name = Mock()
|
||||
self.service._is_valid_ttl = Mock()
|
||||
self.service._is_subzone = Mock(
|
||||
self.service._is_valid_zone_name = mock.Mock()
|
||||
self.service._is_valid_ttl = mock.Mock()
|
||||
self.service._is_subzone = mock.Mock(
|
||||
return_value=False
|
||||
)
|
||||
self.service._is_superzone = Mock(
|
||||
self.service._is_superzone = mock.Mock(
|
||||
return_value=[]
|
||||
)
|
||||
self.service.storage.get_pool.return_value = RoObject(
|
||||
@ -953,7 +952,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
|
||||
def test_find_zones(self):
|
||||
self.context = RoObject(project_id='t')
|
||||
self.service.storage.find_zones = Mock()
|
||||
self.service.storage.find_zones = mock.Mock()
|
||||
self.service.find_zones(self.context)
|
||||
self.assertTrue(self.service.storage.find_zones.called)
|
||||
pcheck, ctx, target = \
|
||||
@ -962,7 +961,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
|
||||
def test_find_zone(self):
|
||||
self.context = RoObject(project_id='t')
|
||||
self.service.storage.find_zone = Mock()
|
||||
self.service.storage.find_zone = mock.Mock()
|
||||
self.service.find_zone(self.context)
|
||||
self.assertTrue(self.service.storage.find_zone.called)
|
||||
pcheck, ctx, target = \
|
||||
@ -1013,7 +1012,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
name='foo',
|
||||
tenant_id='2',
|
||||
)
|
||||
self.service._delete_zone_in_storage = Mock(
|
||||
self.service._delete_zone_in_storage = mock.Mock(
|
||||
return_value=RoObject(
|
||||
name='foo'
|
||||
)
|
||||
@ -1079,9 +1078,9 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual(exceptions.BadRequest, exc.exc_info[0])
|
||||
|
||||
def test_count_report(self):
|
||||
self.service.count_zones = Mock(return_value=1)
|
||||
self.service.count_records = Mock(return_value=2)
|
||||
self.service.count_tenants = Mock(return_value=3)
|
||||
self.service.count_zones = mock.Mock(return_value=1)
|
||||
self.service.count_records = mock.Mock(return_value=2)
|
||||
self.service.count_tenants = mock.Mock(return_value=3)
|
||||
reports = self.service.count_report(
|
||||
self.context,
|
||||
criterion=None
|
||||
@ -1089,9 +1088,9 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual([{'zones': 1, 'records': 2, 'tenants': 3}], reports)
|
||||
|
||||
def test_count_report_zones(self):
|
||||
self.service.count_zones = Mock(return_value=1)
|
||||
self.service.count_records = Mock(return_value=2)
|
||||
self.service.count_tenants = Mock(return_value=3)
|
||||
self.service.count_zones = mock.Mock(return_value=1)
|
||||
self.service.count_records = mock.Mock(return_value=2)
|
||||
self.service.count_tenants = mock.Mock(return_value=3)
|
||||
reports = self.service.count_report(
|
||||
self.context,
|
||||
criterion='zones'
|
||||
@ -1099,9 +1098,9 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual([{'zones': 1}], reports)
|
||||
|
||||
def test_count_report_records(self):
|
||||
self.service.count_zones = Mock(return_value=1)
|
||||
self.service.count_records = Mock(return_value=2)
|
||||
self.service.count_tenants = Mock(return_value=3)
|
||||
self.service.count_zones = mock.Mock(return_value=1)
|
||||
self.service.count_records = mock.Mock(return_value=2)
|
||||
self.service.count_tenants = mock.Mock(return_value=3)
|
||||
reports = self.service.count_report(
|
||||
self.context,
|
||||
criterion='records'
|
||||
@ -1109,9 +1108,9 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual([{'records': 2}], reports)
|
||||
|
||||
def test_count_report_tenants(self):
|
||||
self.service.count_zones = Mock(return_value=1)
|
||||
self.service.count_records = Mock(return_value=2)
|
||||
self.service.count_tenants = Mock(return_value=3)
|
||||
self.service.count_zones = mock.Mock(return_value=1)
|
||||
self.service.count_records = mock.Mock(return_value=2)
|
||||
self.service.count_tenants = mock.Mock(return_value=3)
|
||||
reports = self.service.count_report(
|
||||
self.context,
|
||||
criterion='tenants'
|
||||
@ -1119,9 +1118,9 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual([{'tenants': 3}], reports)
|
||||
|
||||
def test_count_report_not_found(self):
|
||||
self.service.count_zones = Mock(return_value=1)
|
||||
self.service.count_records = Mock(return_value=2)
|
||||
self.service.count_tenants = Mock(return_value=3)
|
||||
self.service.count_zones = mock.Mock(return_value=1)
|
||||
self.service.count_records = mock.Mock(return_value=2)
|
||||
self.service.count_tenants = mock.Mock(return_value=3)
|
||||
|
||||
exc = self.assertRaises(rpc_dispatcher.ExpectedException,
|
||||
self.service.count_report,
|
||||
@ -1131,7 +1130,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual(exceptions.ReportNotFound, exc.exc_info[0])
|
||||
|
||||
def test_touch_zone_with_worker_model(self):
|
||||
self.service._touch_zone_in_storage = Mock()
|
||||
self.service._touch_zone_in_storage = mock.Mock()
|
||||
self.service.storage.get_zone.return_value = RoObject(
|
||||
name='example.org.',
|
||||
tenant_id='2',
|
||||
@ -1192,7 +1191,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
'tenant_id': '2'}, target)
|
||||
|
||||
def test_find_recordsets(self):
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.project_id = 't'
|
||||
self.service.find_recordsets(self.context)
|
||||
self.assertTrue(self.service.storage.find_recordsets.called)
|
||||
@ -1201,7 +1200,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual({'tenant_id': 't'}, target)
|
||||
|
||||
def test_find_recordset(self):
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.project_id = 't'
|
||||
self.service.find_recordset(self.context)
|
||||
self.assertTrue(self.service.storage.find_recordset.called)
|
||||
@ -1211,7 +1210,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
|
||||
def test_update_recordset_fail_on_changes(self):
|
||||
self.service.storage.get_zone.return_value = RoObject()
|
||||
recordset = Mock()
|
||||
recordset = mock.Mock()
|
||||
recordset.obj_get_original_value.return_value = '1'
|
||||
|
||||
recordset.obj_get_changes.return_value = ['tenant_id', 'foo']
|
||||
@ -1242,7 +1241,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.service.storage.get_zone.return_value = RoObject(
|
||||
action='DELETE',
|
||||
)
|
||||
recordset = Mock()
|
||||
recordset = mock.Mock()
|
||||
recordset.obj_get_changes.return_value = ['foo']
|
||||
|
||||
exc = self.assertRaises(rpc_dispatcher.ExpectedException,
|
||||
@ -1259,10 +1258,10 @@ class CentralZoneTestCase(CentralBasic):
|
||||
tenant_id='2',
|
||||
action='bogus',
|
||||
)
|
||||
recordset = Mock()
|
||||
recordset = mock.Mock()
|
||||
recordset.obj_get_changes.return_value = ['foo']
|
||||
recordset.managed = True
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.edit_managed_records = False
|
||||
|
||||
exc = self.assertRaises(rpc_dispatcher.ExpectedException,
|
||||
@ -1279,12 +1278,12 @@ class CentralZoneTestCase(CentralBasic):
|
||||
tenant_id='2',
|
||||
action='bogus',
|
||||
)
|
||||
recordset = Mock()
|
||||
recordset = mock.Mock()
|
||||
recordset.obj_get_changes.return_value = ['foo']
|
||||
recordset.obj_get_original_value.return_value =\
|
||||
'9c85d9b0-1e9d-4e99-aede-a06664f1af2e'
|
||||
recordset.managed = False
|
||||
self.service._update_recordset_in_storage = Mock(
|
||||
self.service._update_recordset_in_storage = mock.Mock(
|
||||
return_value=('x', 'y')
|
||||
)
|
||||
|
||||
@ -1303,18 +1302,18 @@ class CentralZoneTestCase(CentralBasic):
|
||||
'tenant_id': '2'}, target)
|
||||
|
||||
def test__update_recordset_in_storage(self):
|
||||
recordset = Mock()
|
||||
recordset = mock.Mock()
|
||||
recordset.name = 'n'
|
||||
recordset.type = 't'
|
||||
recordset.id = CentralZoneTestCase.recordset__id
|
||||
recordset.obj_get_changes.return_value = {'ttl': 90}
|
||||
recordset.ttl = 90
|
||||
recordset.records = []
|
||||
self.service._is_valid_recordset_name = Mock()
|
||||
self.service._is_valid_recordset_placement = Mock()
|
||||
self.service._is_valid_recordset_placement_subzone = Mock()
|
||||
self.service._is_valid_ttl = Mock()
|
||||
self.service._update_zone_in_storage = Mock()
|
||||
self.service._is_valid_recordset_name = mock.Mock()
|
||||
self.service._is_valid_recordset_placement = mock.Mock()
|
||||
self.service._is_valid_recordset_placement_subzone = mock.Mock()
|
||||
self.service._is_valid_ttl = mock.Mock()
|
||||
self.service._update_zone_in_storage = mock.Mock()
|
||||
|
||||
self.service._update_recordset_in_storage(
|
||||
self.context,
|
||||
@ -1343,7 +1342,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertTrue(self.service._update_zone_in_storage.called)
|
||||
|
||||
def test_update_recordset_in_storage_2(self):
|
||||
recordset = Mock()
|
||||
recordset = mock.Mock()
|
||||
recordset.name = 'n'
|
||||
recordset.type = 't'
|
||||
recordset.id = CentralZoneTestCase.recordset__id
|
||||
@ -1354,10 +1353,10 @@ class CentralZoneTestCase(CentralBasic):
|
||||
status='s',
|
||||
serial=9,
|
||||
)]
|
||||
self.service._is_valid_recordset_name = Mock()
|
||||
self.service._is_valid_recordset_placement = Mock()
|
||||
self.service._is_valid_recordset_placement_subzone = Mock()
|
||||
self.service._update_zone_in_storage = Mock()
|
||||
self.service._is_valid_recordset_name = mock.Mock()
|
||||
self.service._is_valid_recordset_placement = mock.Mock()
|
||||
self.service._is_valid_recordset_placement_subzone = mock.Mock()
|
||||
self.service._update_zone_in_storage = mock.Mock()
|
||||
self.service._enforce_record_quota = mock.Mock()
|
||||
|
||||
self.service._update_recordset_in_storage(
|
||||
@ -1397,7 +1396,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
id=CentralZoneTestCase.recordset__id,
|
||||
managed=False,
|
||||
)
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.edit_managed_records = False
|
||||
|
||||
exc = self.assertRaises(rpc_dispatcher.ExpectedException,
|
||||
@ -1421,7 +1420,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
id=CentralZoneTestCase.recordset__id,
|
||||
managed=False,
|
||||
)
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.edit_managed_records = False
|
||||
|
||||
exc = self.assertRaises(rpc_dispatcher.ExpectedException,
|
||||
@ -1445,7 +1444,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
id=CentralZoneTestCase.recordset__id,
|
||||
managed=True,
|
||||
)
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.edit_managed_records = False
|
||||
|
||||
exc = self.assertRaises(rpc_dispatcher.ExpectedException,
|
||||
@ -1473,9 +1472,9 @@ class CentralZoneTestCase(CentralBasic):
|
||||
|
||||
self.service.storage.get_zone.return_value = mock_zone
|
||||
self.service.storage.get_recordset.return_value = mock_rs
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.edit_managed_records = False
|
||||
self.service._delete_recordset_in_storage = Mock(
|
||||
self.service._delete_recordset_in_storage = mock.Mock(
|
||||
return_value=(mock_rs, mock_zone)
|
||||
)
|
||||
|
||||
@ -1513,7 +1512,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual(1, rs.records[0].serial)
|
||||
|
||||
def test_delete_recordset_in_storage_no_increment_serial(self):
|
||||
self.service._update_zone_in_storage = Mock()
|
||||
self.service._update_zone_in_storage = mock.Mock()
|
||||
self.service._delete_recordset_in_storage(
|
||||
self.context,
|
||||
RoObject(serial=1),
|
||||
@ -1558,7 +1557,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual(exceptions.BadRequest, exc.exc_info[0])
|
||||
|
||||
def _test_create_record(self):
|
||||
self.service._create_record_in_storage = Mock(
|
||||
self.service._create_record_in_storage = mock.Mock(
|
||||
return_value=(None, None)
|
||||
)
|
||||
self.service.storage.get_zone.return_value = RoObject(
|
||||
@ -1595,7 +1594,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self._test_create_record()
|
||||
|
||||
def test__create_record_in_storage(self):
|
||||
self.service._enforce_record_quota = Mock()
|
||||
self.service._enforce_record_quota = mock.Mock()
|
||||
self.service._create_record_in_storage(
|
||||
self.context,
|
||||
RoObject(id=CentralZoneTestCase.zone__id, serial=4),
|
||||
@ -1700,7 +1699,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
type='t',
|
||||
tenant_id='tid',
|
||||
)
|
||||
record = Mock()
|
||||
record = mock.Mock()
|
||||
record.obj_get_original_value.return_value = 1
|
||||
|
||||
record.obj_get_changes.return_value = ['tenant_id', 'foo']
|
||||
@ -1728,7 +1727,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.service.storage.get_zone.return_value = RoObject(
|
||||
action='DELETE',
|
||||
)
|
||||
record = Mock()
|
||||
record = mock.Mock()
|
||||
exc = self.assertRaises(rpc_dispatcher.ExpectedException,
|
||||
self.service.update_record,
|
||||
self.context, record)
|
||||
@ -1746,9 +1745,9 @@ class CentralZoneTestCase(CentralBasic):
|
||||
name='rsn',
|
||||
managed=True
|
||||
)
|
||||
record = Mock()
|
||||
record = mock.Mock()
|
||||
record.obj_get_changes.return_value = ['foo']
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.edit_managed_records = False
|
||||
|
||||
exc = self.assertRaises(rpc_dispatcher.ExpectedException,
|
||||
@ -1768,12 +1767,12 @@ class CentralZoneTestCase(CentralBasic):
|
||||
name='rsn',
|
||||
managed=False
|
||||
)
|
||||
record = Mock()
|
||||
record = mock.Mock()
|
||||
record.obj_get_changes.return_value = ['foo']
|
||||
record.obj_get_original_value.return_value =\
|
||||
'abc12a-1e9d-4e99-aede-a06664f1af2e'
|
||||
record.managed = False
|
||||
self.service._update_record_in_storage = Mock(
|
||||
self.service._update_record_in_storage = mock.Mock(
|
||||
return_value=('x', 'y')
|
||||
)
|
||||
|
||||
@ -1794,7 +1793,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
'tenant_id': 'tid'}, target)
|
||||
|
||||
def test__update_record_in_storage(self):
|
||||
self.service._update_zone_in_storage = Mock()
|
||||
self.service._update_zone_in_storage = mock.Mock()
|
||||
self.service._update_record_in_storage(
|
||||
self.context,
|
||||
RoObject(serial=1),
|
||||
@ -1859,7 +1858,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual(exceptions.RecordNotFound, exc.exc_info[0])
|
||||
|
||||
def test_delete_record_worker(self):
|
||||
self.service._delete_record_in_storage = Mock(
|
||||
self.service._delete_record_in_storage = mock.Mock(
|
||||
return_value=(None, None)
|
||||
)
|
||||
self.service.storage.get_zone.return_value = RoObject(
|
||||
@ -1916,7 +1915,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual({'tenant_id': None}, target)
|
||||
|
||||
def test_sync_zones(self):
|
||||
self.service._sync_zone = Mock()
|
||||
self.service._sync_zone = mock.Mock()
|
||||
self.service.storage.find_zones.return_value = [
|
||||
RoObject(id=CentralZoneTestCase.zone__id),
|
||||
RoObject(id=CentralZoneTestCase.zone__id_2)
|
||||
@ -1928,7 +1927,7 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual(2, len(res))
|
||||
|
||||
def test_sync_zone(self):
|
||||
self.service._sync_zone = Mock()
|
||||
self.service._sync_zone = mock.Mock()
|
||||
self.service.storage.get_zone.return_value = RoObject(
|
||||
id=CentralZoneTestCase.zone__id,
|
||||
name='n',
|
||||
@ -1984,9 +1983,9 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertFalse(r['storage'])
|
||||
|
||||
def test_determine_floatingips(self):
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.project_id = 'tnt'
|
||||
self.service.find_records = Mock(return_value=[
|
||||
self.service.find_records = mock.Mock(return_value=[
|
||||
RoObject(managed_extra='')
|
||||
])
|
||||
|
||||
@ -1997,9 +1996,9 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.assertEqual([], invalid)
|
||||
|
||||
def test_determine_floatingips_with_data(self):
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.project_id = 2
|
||||
self.service.find_records = Mock(return_value=[
|
||||
self.service.find_records = mock.Mock(return_value=[
|
||||
RoObject(managed_extra=1, managed_tenant_id=1),
|
||||
RoObject(managed_extra=2, managed_tenant_id=2),
|
||||
])
|
||||
@ -2069,7 +2068,7 @@ class CentralZoneExportTests(CentralBasic):
|
||||
self.service.storage.find_tld = storage_find_tld
|
||||
|
||||
def test_create_zone_export(self):
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.project_id = 't'
|
||||
|
||||
self.service.storage.get_zone.return_value = RoObject(
|
||||
@ -2077,7 +2076,7 @@ class CentralZoneExportTests(CentralBasic):
|
||||
id=CentralZoneTestCase.zone__id
|
||||
)
|
||||
|
||||
self.service.storage.create_zone_export = Mock(
|
||||
self.service.storage.create_zone_export = mock.Mock(
|
||||
return_value=RwObject(
|
||||
id=CentralZoneTestCase.zone_export__id,
|
||||
zone_id=CentralZoneTestCase.zone__id,
|
||||
@ -2089,7 +2088,7 @@ class CentralZoneExportTests(CentralBasic):
|
||||
)
|
||||
)
|
||||
|
||||
self.service.zone_api.start_zone_export = Mock()
|
||||
self.service.zone_api.start_zone_export = mock.Mock()
|
||||
|
||||
out = self.service.create_zone_export(
|
||||
self.context,
|
||||
@ -2102,7 +2101,7 @@ class CentralZoneExportTests(CentralBasic):
|
||||
self.assertEqual('t', out.tenant_id)
|
||||
|
||||
def test_get_zone_export(self):
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.project_id = 't'
|
||||
|
||||
self.service.storage.get_zone_export.return_value = RoObject(
|
||||
@ -2130,9 +2129,9 @@ class CentralZoneExportTests(CentralBasic):
|
||||
self.assertEqual('t', out.tenant_id)
|
||||
|
||||
def test_find_zone_exports(self):
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.project_id = 't'
|
||||
self.service.storage.find_zone_exports = Mock()
|
||||
self.service.storage.find_zone_exports = mock.Mock()
|
||||
|
||||
self.service.find_zone_exports(self.context)
|
||||
|
||||
@ -2142,10 +2141,10 @@ class CentralZoneExportTests(CentralBasic):
|
||||
self.assertEqual('find_zone_exports', pcheck)
|
||||
|
||||
def test_delete_zone_export(self):
|
||||
self.context = Mock()
|
||||
self.context = mock.Mock()
|
||||
self.context.project_id = 't'
|
||||
|
||||
self.service.storage.delete_zone_export = Mock(
|
||||
self.service.storage.delete_zone_export = mock.Mock(
|
||||
return_value=RoObject(
|
||||
zone_id=CentralZoneTestCase.zone__id,
|
||||
task_type='EXPORT',
|
||||
|
@ -14,8 +14,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import mock
|
||||
from oslo_log import log as logging
|
||||
|
||||
from designate import objects
|
||||
|
@ -9,7 +9,8 @@
|
||||
# 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 mock
|
||||
from unittest import mock
|
||||
|
||||
import oslotest.base
|
||||
|
||||
from designate.conf import opts
|
||||
|
@ -13,7 +13,8 @@
|
||||
# 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 mock
|
||||
from unittest import mock
|
||||
|
||||
import testtools
|
||||
|
||||
import designate.tests
|
||||
|
@ -14,6 +14,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import socket
|
||||
from unittest import mock
|
||||
|
||||
import dns
|
||||
import dns.exception
|
||||
@ -22,7 +23,6 @@ import dns.rcode
|
||||
import dns.rdatatype
|
||||
import dns.zone
|
||||
import eventlet
|
||||
import mock
|
||||
import oslotest.base
|
||||
from dns import zone as dnszone
|
||||
|
||||
|
@ -11,12 +11,13 @@
|
||||
# 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 mock
|
||||
import time
|
||||
from unittest import mock
|
||||
|
||||
import oslotest.base
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as cfg_fixture
|
||||
from oslo_service import loopingcall
|
||||
import time
|
||||
|
||||
from designate import heartbeat_emitter
|
||||
from designate import objects
|
||||
|
@ -10,9 +10,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import random
|
||||
from unittest import mock
|
||||
|
||||
import jinja2
|
||||
import mock
|
||||
import oslotest.base
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
|
@ -13,7 +13,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.mport threading
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
from designate import exceptions
|
||||
from designate.tests import TestCase
|
||||
|
@ -13,7 +13,8 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.mport threading
|
||||
import mock
|
||||
from unittest import mock
|
||||
|
||||
import oslo_messaging as messaging
|
||||
import oslotest.base
|
||||
from oslo_config import cfg
|
||||
|
@ -13,8 +13,9 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.mport threading
|
||||
from unittest import mock
|
||||
|
||||
import dns.exception
|
||||
import mock
|
||||
import oslotest.base
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as cfg_fixture
|
||||
|
@ -59,7 +59,6 @@ logutils==0.3.5
|
||||
Mako==1.0.7
|
||||
MarkupSafe==1.0
|
||||
mccabe==0.2.1
|
||||
mock==3.0.0
|
||||
monasca-statsd==1.4.0
|
||||
monotonic==1.4
|
||||
mox3==0.25.0
|
||||
|
@ -6,7 +6,6 @@
|
||||
hacking>=3.0.1,<3.1.0 # Apache-2.0
|
||||
coverage!=4.4,>=4.0 # Apache-2.0
|
||||
fixtures>=3.0.0 # Apache-2.0/BSD
|
||||
mock>=3.0.0 # BSD
|
||||
stestr>=2.0.0 # Apache-2.0
|
||||
oslotest>=3.2.0 # Apache-2.0
|
||||
requests-mock>=1.2.0 # Apache-2.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user