Add common test base class to hold common things.

There are several common fixtures that every test case wants. Following
the pattern in Nova, add a common base test case class to hold these things.

Change-Id: I2d2cd91e5051d9cbf230e6f48985d6eddcb7b58a
This commit is contained in:
Monty Taylor 2013-02-23 10:35:28 +00:00
parent 5376c174bd
commit a1d52dc22d
83 changed files with 322 additions and 224 deletions

View File

@ -199,7 +199,10 @@ bug that had no unit test, a new passing unit test should be added. If a
submitted bug fix does have a unit test, be sure to add a new one that fails submitted bug fix does have a unit test, be sure to add a new one that fails
without the patch and passes with the patch. without the patch and passes with the patch.
All unittest classes must ultimately inherit from testtools.TestCase. All unittest classes must ultimately inherit from testtools.TestCase. In the
Quantum test suite, this should be done by inheriting from
quantum.tests.base.BaseTestCase.
All setUp and tearDown methods must upcall using the super() method. All setUp and tearDown methods must upcall using the super() method.
tearDown methods should be avoided and addCleanup calls should be preferred. tearDown methods should be avoided and addCleanup calls should be preferred.
Never manually create tempfiles. Always use the tempfile fixtures from Never manually create tempfiles. Always use the tempfile fixtures from

View File

@ -22,7 +22,6 @@ import logging
import os.path import os.path
import routes import routes
import testtools
import webob import webob
from webtest import TestApp from webtest import TestApp
@ -42,6 +41,7 @@ from quantum.openstack.common import jsonutils
from quantum.plugins.cisco.db import api as db from quantum.plugins.cisco.db import api as db
from quantum.plugins.cisco import l2network_plugin from quantum.plugins.cisco import l2network_plugin
from quantum.plugins.cisco.l2network_plugin import L2Network from quantum.plugins.cisco.l2network_plugin import L2Network
from quantum.tests import base
from quantum.tests.unit.extension_stubs import StubBaseAppController from quantum.tests.unit.extension_stubs import StubBaseAppController
from quantum import wsgi from quantum import wsgi
@ -150,7 +150,7 @@ class ExtensionsTestApp(wsgi.Router):
self._delete_network(net_id) self._delete_network(net_id)
class QosExtensionTest(testtools.TestCase): class QosExtensionTest(base.BaseTestCase):
def setUp(self): def setUp(self):
@ -406,7 +406,7 @@ class QosExtensionTest(testtools.TestCase):
db.clear_db() db.clear_db()
class CredentialExtensionTest(testtools.TestCase): class CredentialExtensionTest(base.BaseTestCase):
def setUp(self): def setUp(self):

View File

@ -22,13 +22,12 @@ that tests the database api method calls
import logging as LOG import logging as LOG
import testtools
from quantum.openstack.common import log as logging from quantum.openstack.common import log as logging
from quantum.plugins.cisco.common import cisco_constants as const from quantum.plugins.cisco.common import cisco_constants as const
import quantum.plugins.cisco.db.api as db import quantum.plugins.cisco.db.api as db
import quantum.plugins.cisco.db.l2network_db as l2network_db import quantum.plugins.cisco.db.l2network_db as l2network_db
import quantum.plugins.cisco.db.nexus_db_v2 as nexus_db import quantum.plugins.cisco.db.nexus_db_v2 as nexus_db
from quantum.tests import base
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -347,7 +346,7 @@ class QuantumDB(object):
raise Exception("Failed to unplug interface: %s" % str(exc)) raise Exception("Failed to unplug interface: %s" % str(exc))
class NexusDBTest(testtools.TestCase): class NexusDBTest(base.BaseTestCase):
"""Class conisting of nexus DB unit tests""" """Class conisting of nexus DB unit tests"""
def setUp(self): def setUp(self):
super(NexusDBTest, self).setUp() super(NexusDBTest, self).setUp()
@ -409,7 +408,7 @@ class NexusDBTest(testtools.TestCase):
self.dbtest.delete_nexusportbinding(vlan_id) self.dbtest.delete_nexusportbinding(vlan_id)
class L2networkDBTest(testtools.TestCase): class L2networkDBTest(base.BaseTestCase):
"""Class conisting of L2network DB unit tests""" """Class conisting of L2network DB unit tests"""
def setUp(self): def setUp(self):
"""Setup for tests""" """Setup for tests"""
@ -515,7 +514,7 @@ class L2networkDBTest(testtools.TestCase):
self.dbtest.delete_vlan_binding(netid) self.dbtest.delete_vlan_binding(netid)
class QuantumDBTest(testtools.TestCase): class QuantumDBTest(base.BaseTestCase):
"""Class conisting of Quantum DB unit tests""" """Class conisting of Quantum DB unit tests"""
def setUp(self): def setUp(self):
"""Setup for tests""" """Setup for tests"""

72
quantum/tests/base.py Normal file
View File

@ -0,0 +1,72 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010-2011 OpenStack, LLC
# All Rights Reserved.
#
# 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.
"""Base Test Case for all Unit Tests"""
import os
import fixtures
from oslo.config import cfg
import testtools
CONF = cfg.CONF
TRUE_STRING = ['True', '1']
class BaseTestCase(testtools.TestCase):
def setUp(self):
super(BaseTestCase, self).setUp()
self.useFixture(fixtures.FakeLogger(
format="%(asctime)s %(levelname)8s [%(name)s] %(message)s"))
test_timeout = int(os.environ.get('OS_TEST_TIMEOUT', 0))
if test_timeout == -1:
test_timeout = 0
if test_timeout > 0:
self.useFixture(fixtures.Timeout(test_timeout, gentle=True))
# If someone does use tempfile directly, ensure that it's cleaned up
self.useFixture(fixtures.NestedTempfile())
self.useFixture(fixtures.TempHomeDir())
self.addCleanup(CONF.reset)
if os.environ.get('OS_STDOUT_NOCAPTURE') not in TRUE_STRING:
stdout = self.useFixture(fixtures.StringStream('stdout')).stream
self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
if os.environ.get('OS_STDERR_NOCAPTURE') not in TRUE_STRING:
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
def config(self, **kw):
"""
Override some configuration values.
The keyword arguments are the names of configuration options to
override and their values.
If a group argument is supplied, the overrides are applied to
the specified configuration option group.
All overrides are automatically cleared at the end of the current
test by the fixtures cleanup process.
"""
group = kw.pop('group', None)
for k, v in kw.iteritems():
CONF.set_override(k, v, group)

View File

@ -21,8 +21,6 @@
import __builtin__ import __builtin__
import os import os
import testtools
setattr(__builtin__, '_', lambda x: x) setattr(__builtin__, '_', lambda x: x)
from oslo.config import cfg from oslo.config import cfg
@ -34,3 +32,4 @@ cfg.CONF.state_path = absdir
# An empty lock path forces lockutils.synchronized to use a temporary # An empty lock path forces lockutils.synchronized to use a temporary
# location for lock files that will be cleaned up automatically. # location for lock files that will be cleaned up automatically.
cfg.CONF.lock_path = '' cfg.CONF.lock_path = ''
cfg.CONF.use_stderr = False

View File

@ -18,16 +18,16 @@
import os import os
import fixtures import fixtures
import testtools
from quantum.agent.linux import utils from quantum.agent.linux import utils
from quantum.openstack.common import log as logging from quantum.openstack.common import log as logging
from quantum.tests import base
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class RootwrapTestExec(testtools.TestCase): class RootwrapTestExec(base.BaseTestCase):
"""Simple unit test to test the basic rootwrap mechanism """Simple unit test to test the basic rootwrap mechanism
Essentially hello-world. Just run a command as root and check that Essentially hello-world. Just run a command as root and check that

View File

@ -19,14 +19,14 @@
""" """
Test vlans alloc/dealloc. Test vlans alloc/dealloc.
""" """
import testtools
from quantum.db import api as db from quantum.db import api as db
from quantum.openstack.common import context from quantum.openstack.common import context
from quantum.plugins.brocade import vlanbm as vlan_bitmap from quantum.plugins.brocade import vlanbm as vlan_bitmap
from quantum.tests import base
class TestVlanBitmap(testtools.TestCase): class TestVlanBitmap(base.BaseTestCase):
"""exercise Vlan bitmap .""" """exercise Vlan bitmap ."""
def setUp(self): def setUp(self):

View File

@ -14,13 +14,13 @@
# limitations under the License. # limitations under the License.
import mock import mock
import testtools
from quantum.db import api as db from quantum.db import api as db
from quantum.openstack.common import importutils from quantum.openstack.common import importutils
from quantum.plugins.cisco.common import cisco_constants as const from quantum.plugins.cisco.common import cisco_constants as const
from quantum.plugins.cisco.db import network_models_v2 from quantum.plugins.cisco.db import network_models_v2
from quantum.plugins.cisco.nexus import cisco_nexus_plugin_v2 from quantum.plugins.cisco.nexus import cisco_nexus_plugin_v2
from quantum.tests import base
NEXUS_IP_ADDRESS = '1.1.1.1' NEXUS_IP_ADDRESS = '1.1.1.1'
@ -34,7 +34,7 @@ NEXUS_DRIVER = ('quantum.plugins.cisco.tests.unit.v2.nexus.'
'fake_nexus_driver.CiscoNEXUSFakeDriver') 'fake_nexus_driver.CiscoNEXUSFakeDriver')
class TestCiscoNexusPlugin(testtools.TestCase): class TestCiscoNexusPlugin(base.BaseTestCase):
def setUp(self): def setUp(self):
""" """

View File

@ -24,12 +24,12 @@ import sys
import mock import mock
from oslo.config import cfg from oslo.config import cfg
import testtools
from quantum.plugins.hyperv.agent import hyperv_quantum_agent from quantum.plugins.hyperv.agent import hyperv_quantum_agent
from quantum.tests import base
class TestHyperVQuantumAgent(testtools.TestCase): class TestHyperVQuantumAgent(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestHyperVQuantumAgent, self).setUp() super(TestHyperVQuantumAgent, self).setUp()

View File

@ -21,7 +21,6 @@ Unit Tests for hyperv quantum rpc
""" """
import mock import mock
import testtools
from quantum.agent import rpc as agent_rpc from quantum.agent import rpc as agent_rpc
from quantum.common import topics from quantum.common import topics
@ -29,9 +28,10 @@ from quantum.openstack.common import context
from quantum.openstack.common import rpc from quantum.openstack.common import rpc
from quantum.plugins.hyperv import agent_notifier_api as ana from quantum.plugins.hyperv import agent_notifier_api as ana
from quantum.plugins.hyperv.common import constants from quantum.plugins.hyperv.common import constants
from quantum.tests import base
class rpcHyperVApiTestCase(testtools.TestCase): class rpcHyperVApiTestCase(base.BaseTestCase):
def _test_hyperv_quantum_api( def _test_hyperv_quantum_api(
self, rpcapi, topic, method, rpc_method, **kwargs): self, rpcapi, topic, method, rpc_method, **kwargs):

View File

@ -14,13 +14,13 @@
# limitations under the License. # limitations under the License.
from oslo.config import cfg from oslo.config import cfg
import testtools
#NOTE this import loads tests required options #NOTE this import loads tests required options
from quantum.plugins.linuxbridge.common import config from quantum.plugins.linuxbridge.common import config
from quantum.tests import base
class ConfigurationTest(testtools.TestCase): class ConfigurationTest(base.BaseTestCase):
def test_defaults(self): def test_defaults(self):
self.assertEqual(-1, self.assertEqual(-1,

View File

@ -19,6 +19,7 @@ from testtools import matchers
from quantum.common import exceptions as q_exc from quantum.common import exceptions as q_exc
from quantum.db import api as db from quantum.db import api as db
from quantum.plugins.linuxbridge.db import l2network_db_v2 as lb_db from quantum.plugins.linuxbridge.db import l2network_db_v2 as lb_db
from quantum.tests import base
from quantum.tests.unit import test_db_plugin as test_plugin from quantum.tests.unit import test_db_plugin as test_plugin
PHYS_NET = 'physnet1' PHYS_NET = 'physnet1'
@ -30,7 +31,7 @@ UPDATED_VLAN_RANGES = {PHYS_NET: [(VLAN_MIN + 5, VLAN_MAX + 5)],
PHYS_NET_2: [(VLAN_MIN + 20, VLAN_MAX + 20)]} PHYS_NET_2: [(VLAN_MIN + 20, VLAN_MAX + 20)]}
class NetworkStatesTest(testtools.TestCase): class NetworkStatesTest(base.BaseTestCase):
def setUp(self): def setUp(self):
super(NetworkStatesTest, self).setUp() super(NetworkStatesTest, self).setUp()
lb_db.initialize() lb_db.initialize()

View File

@ -22,9 +22,10 @@ import testtools
from quantum.plugins.linuxbridge.agent import linuxbridge_quantum_agent from quantum.plugins.linuxbridge.agent import linuxbridge_quantum_agent
from quantum.plugins.linuxbridge.common import constants as lconst from quantum.plugins.linuxbridge.common import constants as lconst
from quantum.tests import base
class TestLinuxBridge(testtools.TestCase): class TestLinuxBridge(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestLinuxBridge, self).setUp() super(TestLinuxBridge, self).setUp()
@ -56,7 +57,7 @@ class TestLinuxBridge(testtools.TestCase):
self.assertTrue(vlan_bridge_func.called) self.assertTrue(vlan_bridge_func.called)
class TestLinuxBridgeAgent(testtools.TestCase): class TestLinuxBridgeAgent(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestLinuxBridgeAgent, self).setUp() super(TestLinuxBridgeAgent, self).setUp()

View File

@ -19,16 +19,16 @@ Unit Tests for linuxbridge rpc
""" """
import stubout import stubout
import testtools
from quantum.agent import rpc as agent_rpc from quantum.agent import rpc as agent_rpc
from quantum.common import topics from quantum.common import topics
from quantum.openstack.common import context from quantum.openstack.common import context
from quantum.openstack.common import rpc from quantum.openstack.common import rpc
from quantum.plugins.linuxbridge import lb_quantum_plugin as plb from quantum.plugins.linuxbridge import lb_quantum_plugin as plb
from quantum.tests import base
class rpcApiTestCase(testtools.TestCase): class rpcApiTestCase(base.BaseTestCase):
def _test_lb_api(self, rpcapi, topic, method, rpc_method, **kwargs): def _test_lb_api(self, rpcapi, topic, method, rpc_method, **kwargs):
ctxt = context.RequestContext('fake_user', 'fake_project') ctxt = context.RequestContext('fake_user', 'fake_project')

View File

@ -30,6 +30,7 @@ from quantum.extensions.flavor import (FLAVOR_NETWORK, FLAVOR_ROUTER)
from quantum.openstack.common import uuidutils from quantum.openstack.common import uuidutils
from quantum.plugins.metaplugin.meta_quantum_plugin import FlavorNotFound from quantum.plugins.metaplugin.meta_quantum_plugin import FlavorNotFound
from quantum.plugins.metaplugin.meta_quantum_plugin import MetaPluginV2 from quantum.plugins.metaplugin.meta_quantum_plugin import MetaPluginV2
from quantum.tests import base
CONF_FILE = "" CONF_FILE = ""
ROOTDIR = os.path.dirname(os.path.dirname(__file__)) ROOTDIR = os.path.dirname(os.path.dirname(__file__))
@ -67,7 +68,7 @@ def setup_metaplugin_conf():
'quantum.openstack.common.rpc.impl_fake') 'quantum.openstack.common.rpc.impl_fake')
class MetaQuantumPluginV2Test(testtools.TestCase): class MetaQuantumPluginV2Test(base.BaseTestCase):
"""Class conisting of MetaQuantumPluginV2 unit tests""" """Class conisting of MetaQuantumPluginV2 unit tests"""
def setUp(self): def setUp(self):

View File

@ -19,15 +19,15 @@
# @author: Ryu Ishimoto, Midokura Japan KK # @author: Ryu Ishimoto, Midokura Japan KK
# @author: Tomoe Sugihara, Midokura Japan KK # @author: Tomoe Sugihara, Midokura Japan KK
import testtools
import uuid import uuid
import mock import mock
from quantum.plugins.midonet import midonet_lib from quantum.plugins.midonet import midonet_lib
from quantum.tests import base
class MidonetLibTestCase(testtools.TestCase): class MidonetLibTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(MidonetLibTestCase, self).setUp() super(MidonetLibTestCase, self).setUp()

View File

@ -15,12 +15,11 @@
# under the License. # under the License.
# @author: Ryota MIBU # @author: Ryota MIBU
import testtools
from quantum.plugins.nec.common import config from quantum.plugins.nec.common import config
from quantum.tests import base
class ConfigurationTest(testtools.TestCase): class ConfigurationTest(base.BaseTestCase):
def test_defaults(self): def test_defaults(self):
self.assertEqual(-1, config.CONF.DATABASE.sql_max_retries) self.assertEqual(-1, config.CONF.DATABASE.sql_max_retries)

View File

@ -16,16 +16,16 @@
# @author: Ryota MIBU # @author: Ryota MIBU
import random import random
import testtools
from quantum.db import api as db_api from quantum.db import api as db_api
from quantum.openstack.common import uuidutils from quantum.openstack.common import uuidutils
from quantum.plugins.nec.common import exceptions as nexc from quantum.plugins.nec.common import exceptions as nexc
from quantum.plugins.nec.db import api as ndb from quantum.plugins.nec.db import api as ndb
from quantum.plugins.nec.db import models as nmodels from quantum.plugins.nec.db import models as nmodels
from quantum.tests import base
class NECPluginV2DBTestBase(testtools.TestCase): class NECPluginV2DBTestBase(base.BaseTestCase):
"""Class conisting of NECPluginV2 DB unit tests""" """Class conisting of NECPluginV2 DB unit tests"""
def setUp(self): def setUp(self):

View File

@ -15,17 +15,16 @@
# under the License. # under the License.
# @author: Ryota MIBU # @author: Ryota MIBU
import testtools
from quantum import context from quantum import context
from quantum.openstack.common import uuidutils from quantum.openstack.common import uuidutils
from quantum.plugins.nec.common import config from quantum.plugins.nec.common import config
from quantum.plugins.nec.db import api as ndb from quantum.plugins.nec.db import api as ndb
from quantum.plugins.nec.db import models as nmodels from quantum.plugins.nec.db import models as nmodels
from quantum.plugins.nec import ofc_manager from quantum.plugins.nec import ofc_manager
from quantum.tests import base
class OFCManagerTestBase(testtools.TestCase): class OFCManagerTestBase(base.BaseTestCase):
"""Class conisting of OFCManager unit tests""" """Class conisting of OFCManager unit tests"""
def setUp(self): def setUp(self):

View File

@ -19,7 +19,6 @@ import random
import string import string
import mox import mox
import testtools
from quantum import context from quantum import context
from quantum.openstack.common import uuidutils from quantum.openstack.common import uuidutils
@ -27,6 +26,7 @@ from quantum.plugins.nec.common import ofc_client as ofc
from quantum.plugins.nec.db import api as ndb from quantum.plugins.nec.db import api as ndb
from quantum.plugins.nec.db import models as nmodels from quantum.plugins.nec.db import models as nmodels
from quantum.plugins.nec import drivers from quantum.plugins.nec import drivers
from quantum.tests import base
class TestConfig(object): class TestConfig(object):
@ -43,7 +43,7 @@ def _ofc(id):
return "ofc-%s" % id return "ofc-%s" % id
class PFCDriverTestBase(testtools.TestCase): class PFCDriverTestBase(base.BaseTestCase):
driver = 'quantum.plugins.nec.drivers.pfc.PFCDriverBase' driver = 'quantum.plugins.nec.drivers.pfc.PFCDriverBase'
@ -192,7 +192,7 @@ class PFCV4DriverTest(PFCDriverTestBase):
driver = 'pfc_v4' driver = 'pfc_v4'
class PFCDriverStringTest(testtools.TestCase): class PFCDriverStringTest(base.BaseTestCase):
driver = 'quantum.plugins.nec.drivers.pfc.PFCDriverBase' driver = 'quantum.plugins.nec.drivers.pfc.PFCDriverBase'
@ -235,7 +235,7 @@ class PFCDriverStringTest(testtools.TestCase):
self.assertEqual(exp_str, ret_str) self.assertEqual(exp_str, ret_str)
class PFCIdConvertTest(testtools.TestCase): class PFCIdConvertTest(base.BaseTestCase):
driver = 'quantum.plugins.nec.drivers.pfc.PFCDriverBase' driver = 'quantum.plugins.nec.drivers.pfc.PFCDriverBase'
def setUp(self): def setUp(self):

View File

@ -16,7 +16,6 @@
# @author: Ryota MIBU # @author: Ryota MIBU
import mox import mox
import testtools
from quantum import context from quantum import context
from quantum.openstack.common import uuidutils from quantum.openstack.common import uuidutils
@ -24,6 +23,7 @@ from quantum.plugins.nec.common import ofc_client
from quantum.plugins.nec.db import api as ndb from quantum.plugins.nec.db import api as ndb
from quantum.plugins.nec.db import models as nmodels from quantum.plugins.nec.db import models as nmodels
from quantum.plugins.nec import drivers from quantum.plugins.nec import drivers
from quantum.tests import base
class TestConfig(object): class TestConfig(object):
@ -32,7 +32,7 @@ class TestConfig(object):
port = 8888 port = 8888
class TremaDriverTestBase(testtools.TestCase): class TremaDriverTestBase(base.BaseTestCase):
driver_name = "trema" driver_name = "trema"
@ -245,7 +245,7 @@ def generate_random_ids(count=1):
return [uuidutils.generate_uuid() for i in xrange(count)] return [uuidutils.generate_uuid() for i in xrange(count)]
class TremaIdConvertTest(testtools.TestCase): class TremaIdConvertTest(base.BaseTestCase):
driver_name = 'trema' driver_name = 'trema'
def setUp(self): def setUp(self):
@ -288,7 +288,7 @@ class TremaIdConvertTest(testtools.TestCase):
self.assertEqual(ret, ofc_f_id) self.assertEqual(ret, ofc_f_id)
class TremaIdConvertTestBase(testtools.TestCase): class TremaIdConvertTestBase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TremaIdConvertTestBase, self).setUp() super(TremaIdConvertTestBase, self).setUp()
self.mox = mox.Mox() self.mox = mox.Mox()

View File

@ -13,14 +13,13 @@
# under the License. # under the License.
# #
import testtools
from oslo.config import cfg from oslo.config import cfg
from quantum.plugins.nicira.nicira_nvp_plugin.common import config from quantum.plugins.nicira.nicira_nvp_plugin.common import config
from quantum.tests import base
class ConfigurationTest(testtools.TestCase): class ConfigurationTest(base.BaseTestCase):
def test_defaults(self): def test_defaults(self):
self.assertEqual(-1, cfg.CONF.DATABASE.sql_max_retries) self.assertEqual(-1, cfg.CONF.DATABASE.sql_max_retries)

View File

@ -32,6 +32,7 @@ from quantum import manager
from quantum.plugins.nicira.nicira_nvp_plugin.extensions import (nvp_networkgw from quantum.plugins.nicira.nicira_nvp_plugin.extensions import (nvp_networkgw
as networkgw) as networkgw)
from quantum.plugins.nicira.nicira_nvp_plugin import nicira_networkgw_db from quantum.plugins.nicira.nicira_nvp_plugin import nicira_networkgw_db
from quantum.tests import base
from quantum.tests.unit import test_api_v2 from quantum.tests.unit import test_api_v2
from quantum.tests.unit import test_db_plugin from quantum.tests.unit import test_db_plugin
from quantum.tests.unit import test_extensions from quantum.tests.unit import test_extensions
@ -53,7 +54,7 @@ class TestExtensionManager(object):
return [] return []
class NetworkGatewayExtensionTestCase(testtools.TestCase): class NetworkGatewayExtensionTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(NetworkGatewayExtensionTestCase, self).setUp() super(NetworkGatewayExtensionTestCase, self).setUp()

View File

@ -8,14 +8,12 @@
# System # System
import httplib import httplib
# Third party
import testtools
# Local # Local
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.common as naco import quantum.plugins.nicira.nicira_nvp_plugin.api_client.common as naco
from quantum.tests import base
class NvpApiCommonTest(testtools.TestCase): class NvpApiCommonTest(base.BaseTestCase):
def test_conn_str(self): def test_conn_str(self):
conn = httplib.HTTPSConnection('localhost', 4242, timeout=0) conn = httplib.HTTPSConnection('localhost', 4242, timeout=0)

View File

@ -10,7 +10,7 @@ eventlet.monkey_patch()
import logging import logging
import urllib2 import urllib2
import testtools from quantum.tests import base
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
lg = logging.getLogger("test_nvp_api_request") lg = logging.getLogger("test_nvp_api_request")
@ -22,6 +22,6 @@ def fetch(url):
return urllib2.urlopen(url).read() return urllib2.urlopen(url).read()
class NvpApiRequestTest(testtools.TestCase): class NvpApiRequestTest(base.BaseTestCase):
pass pass

View File

@ -21,12 +21,12 @@ import eventlet
from eventlet.green import urllib2 from eventlet.green import urllib2
from mock import Mock from mock import Mock
from mock import patch from mock import patch
import testtools
from quantum.plugins.nicira.nicira_nvp_plugin.api_client import ( from quantum.plugins.nicira.nicira_nvp_plugin.api_client import (
client_eventlet as nace, client_eventlet as nace,
request_eventlet as nare, request_eventlet as nare,
) )
from quantum.tests import base
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
@ -40,7 +40,7 @@ def fetch(url):
return urllib2.urlopen(url).read() return urllib2.urlopen(url).read()
class NvpApiRequestEventletTest(testtools.TestCase): class NvpApiRequestEventletTest(base.BaseTestCase):
def setUp(self): def setUp(self):

View File

@ -18,13 +18,12 @@
import mock import mock
import os import os
import testtools
from quantum.openstack.common import jsonutils as json from quantum.openstack.common import jsonutils as json
import quantum.plugins.nicira.nicira_nvp_plugin as nvp_plugin import quantum.plugins.nicira.nicira_nvp_plugin as nvp_plugin
from quantum.plugins.nicira.nicira_nvp_plugin import nvp_cluster from quantum.plugins.nicira.nicira_nvp_plugin import nvp_cluster
from quantum.plugins.nicira.nicira_nvp_plugin import NvpApiClient from quantum.plugins.nicira.nicira_nvp_plugin import NvpApiClient
from quantum.plugins.nicira.nicira_nvp_plugin import nvplib from quantum.plugins.nicira.nicira_nvp_plugin import nvplib
from quantum.tests import base
from quantum.tests.unit.nicira import fake_nvpapiclient from quantum.tests.unit.nicira import fake_nvpapiclient
from quantum.tests.unit import test_api_v2 from quantum.tests.unit import test_api_v2
@ -32,7 +31,7 @@ NICIRA_PKG_PATH = nvp_plugin.__name__
_uuid = test_api_v2._uuid _uuid = test_api_v2._uuid
class NvplibTestCase(testtools.TestCase): class NvplibTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
# mock nvp api client # mock nvp api client

View File

@ -19,6 +19,7 @@ from testtools import matchers
from quantum.common import exceptions as q_exc from quantum.common import exceptions as q_exc
from quantum.db import api as db from quantum.db import api as db
from quantum.plugins.openvswitch import ovs_db_v2 from quantum.plugins.openvswitch import ovs_db_v2
from quantum.tests import base
from quantum.tests.unit import test_db_plugin as test_plugin from quantum.tests.unit import test_db_plugin as test_plugin
PHYS_NET = 'physnet1' PHYS_NET = 'physnet1'
@ -34,7 +35,7 @@ TUNNEL_RANGES = [(TUN_MIN, TUN_MAX)]
UPDATED_TUNNEL_RANGES = [(TUN_MIN + 5, TUN_MAX + 5)] UPDATED_TUNNEL_RANGES = [(TUN_MIN + 5, TUN_MAX + 5)]
class VlanAllocationsTest(testtools.TestCase): class VlanAllocationsTest(base.BaseTestCase):
def setUp(self): def setUp(self):
super(VlanAllocationsTest, self).setUp() super(VlanAllocationsTest, self).setUp()
ovs_db_v2.initialize() ovs_db_v2.initialize()
@ -178,7 +179,7 @@ class VlanAllocationsTest(testtools.TestCase):
ovs_db_v2.sync_vlan_allocations({}) ovs_db_v2.sync_vlan_allocations({})
class TunnelAllocationsTest(testtools.TestCase): class TunnelAllocationsTest(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TunnelAllocationsTest, self).setUp() super(TunnelAllocationsTest, self).setUp()
ovs_db_v2.initialize() ovs_db_v2.initialize()

View File

@ -13,15 +13,14 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import testtools
from oslo.config import cfg from oslo.config import cfg
#NOTE this import loads tests required options #NOTE this import loads tests required options
from quantum.plugins.openvswitch.common import config from quantum.plugins.openvswitch.common import config
from quantum.tests import base
class ConfigurationTest(testtools.TestCase): class ConfigurationTest(base.BaseTestCase):
def test_defaults(self): def test_defaults(self):
self.assertEqual('br-int', cfg.CONF.OVS.integration_bridge) self.assertEqual('br-int', cfg.CONF.OVS.integration_bridge)

View File

@ -16,13 +16,13 @@
# @author: Dan Wendlandt, Nicira, Inc. # @author: Dan Wendlandt, Nicira, Inc.
import mox import mox
import testtools
from quantum.agent.linux import ovs_lib, utils from quantum.agent.linux import ovs_lib, utils
from quantum.openstack.common import uuidutils from quantum.openstack.common import uuidutils
from quantum.tests import base
class OVS_Lib_Test(testtools.TestCase): class OVS_Lib_Test(base.BaseTestCase):
""" """
A test suite to excercise the OVS libraries shared by Quantum agents. A test suite to excercise the OVS libraries shared by Quantum agents.
Note: these tests do not actually execute ovs-* utilities, and thus Note: these tests do not actually execute ovs-* utilities, and thus

View File

@ -19,13 +19,14 @@ from oslo.config import cfg
import testtools import testtools
from quantum.plugins.openvswitch.agent import ovs_quantum_agent from quantum.plugins.openvswitch.agent import ovs_quantum_agent
from quantum.tests import base
NOTIFIER = ('quantum.plugins.openvswitch.' NOTIFIER = ('quantum.plugins.openvswitch.'
'ovs_quantum_plugin.AgentNotifierApi') 'ovs_quantum_plugin.AgentNotifierApi')
class CreateAgentConfigMap(testtools.TestCase): class CreateAgentConfigMap(base.BaseTestCase):
def test_create_agent_config_map_succeeds(self): def test_create_agent_config_map_succeeds(self):
self.assertTrue(ovs_quantum_agent.create_agent_config_map(cfg.CONF)) self.assertTrue(ovs_quantum_agent.create_agent_config_map(cfg.CONF))
@ -38,7 +39,7 @@ class CreateAgentConfigMap(testtools.TestCase):
ovs_quantum_agent.create_agent_config_map(cfg.CONF) ovs_quantum_agent.create_agent_config_map(cfg.CONF)
class TestOvsQuantumAgent(testtools.TestCase): class TestOvsQuantumAgent(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestOvsQuantumAgent, self).setUp() super(TestOvsQuantumAgent, self).setUp()

View File

@ -19,7 +19,6 @@ Unit Tests for openvswitch rpc
""" """
import stubout import stubout
import testtools
from quantum.agent import rpc as agent_rpc from quantum.agent import rpc as agent_rpc
from quantum.common import topics from quantum.common import topics
@ -27,9 +26,10 @@ from quantum.openstack.common import context
from quantum.openstack.common import rpc from quantum.openstack.common import rpc
from quantum.plugins.openvswitch.common import constants from quantum.plugins.openvswitch.common import constants
from quantum.plugins.openvswitch import ovs_quantum_plugin as povs from quantum.plugins.openvswitch import ovs_quantum_plugin as povs
from quantum.tests import base
class rpcApiTestCase(testtools.TestCase): class rpcApiTestCase(base.BaseTestCase):
def _test_ovs_api(self, rpcapi, topic, method, rpc_method, **kwargs): def _test_ovs_api(self, rpcapi, topic, method, rpc_method, **kwargs):
ctxt = context.RequestContext('fake_user', 'fake_project') ctxt = context.RequestContext('fake_user', 'fake_project')

View File

@ -18,7 +18,6 @@
import mox import mox
from oslo.config import cfg from oslo.config import cfg
import testtools
from quantum.agent.linux import ip_lib from quantum.agent.linux import ip_lib
from quantum.agent.linux import ovs_lib from quantum.agent.linux import ovs_lib
@ -27,6 +26,7 @@ from quantum.agent import rpc
from quantum.openstack.common import log from quantum.openstack.common import log
from quantum.plugins.openvswitch.agent import ovs_quantum_agent from quantum.plugins.openvswitch.agent import ovs_quantum_agent
from quantum.plugins.openvswitch.common import constants from quantum.plugins.openvswitch.common import constants
from quantum.tests import base
# Useful global dummy variables. # Useful global dummy variables.
@ -59,7 +59,7 @@ class DummyVlanBinding:
self.vlan_id = vlan_id self.vlan_id = vlan_id
class TunnelTest(testtools.TestCase): class TunnelTest(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TunnelTest, self).setUp() super(TunnelTest, self).setUp()

View File

@ -16,13 +16,13 @@
# under the License. # under the License.
from oslo.config import cfg from oslo.config import cfg
import testtools
#NOTE this import loads tests required options #NOTE this import loads tests required options
from quantum.plugins.ryu.common import config from quantum.plugins.ryu.common import config
from quantum.tests import base
class ConfigurationTest(testtools.TestCase): class ConfigurationTest(base.BaseTestCase):
"""Configuration file Tests""" """Configuration file Tests"""
def test_defaults(self): def test_defaults(self):
self.assertEqual('br-int', cfg.CONF.OVS.integration_bridge) self.assertEqual('br-int', cfg.CONF.OVS.integration_bridge)

View File

@ -17,14 +17,13 @@ from contextlib import nested
import httplib import httplib
import mock import mock
from oslo.config import cfg
import testtools
from quantum.openstack.common import importutils from quantum.openstack.common import importutils
from quantum.tests import base
from quantum.tests.unit.ryu import fake_ryu from quantum.tests.unit.ryu import fake_ryu
class RyuAgentTestCase(testtools.TestCase): class RyuAgentTestCase(base.BaseTestCase):
_AGENT_NAME = 'quantum.plugins.ryu.agent.ryu_quantum_agent' _AGENT_NAME = 'quantum.plugins.ryu.agent.ryu_quantum_agent'

View File

@ -17,12 +17,12 @@
# @author: Mark McClain, DreamHost # @author: Mark McClain, DreamHost
import mock import mock
import testtools
from quantum.plugins.services.agent_loadbalancer.agent import api from quantum.plugins.services.agent_loadbalancer.agent import api
from quantum.tests import base
class TestApiCache(testtools.TestCase): class TestApiCache(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestApiCache, self).setUp() super(TestApiCache, self).setUp()
self.addCleanup(mock.patch.stopall) self.addCleanup(mock.patch.stopall)

View File

@ -22,9 +22,10 @@ from oslo.config import cfg
import testtools import testtools
from quantum.plugins.services.agent_loadbalancer import agent from quantum.plugins.services.agent_loadbalancer import agent
from quantum.tests import base
class TestLbaasService(testtools.TestCase): class TestLbaasService(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestLbaasService, self).setUp() super(TestLbaasService, self).setUp()
self.addCleanup(cfg.CONF.reset) self.addCleanup(cfg.CONF.reset)

View File

@ -19,12 +19,12 @@
import contextlib import contextlib
import mock import mock
import testtools
from quantum.plugins.services.agent_loadbalancer.agent import manager from quantum.plugins.services.agent_loadbalancer.agent import manager
from quantum.tests import base
class TestLogicalDeviceCache(testtools.TestCase): class TestLogicalDeviceCache(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestLogicalDeviceCache, self).setUp() super(TestLogicalDeviceCache, self).setUp()
self.cache = manager.LogicalDeviceCache() self.cache = manager.LogicalDeviceCache()
@ -131,7 +131,7 @@ class TestLogicalDeviceCache(testtools.TestCase):
self.assertEqual(self.cache.get_pool_ids(), ['pool_id']) self.assertEqual(self.cache.get_pool_ids(), ['pool_id'])
class TestManager(testtools.TestCase): class TestManager(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestManager, self).setUp() super(TestManager, self).setUp()
self.addCleanup(mock.patch.stopall) self.addCleanup(mock.patch.stopall)

View File

@ -19,14 +19,14 @@
import contextlib import contextlib
import mock import mock
import testtools
from oslo.config import cfg as config from oslo.config import cfg as config
from quantum.plugins.services.agent_loadbalancer.drivers.haproxy import cfg from quantum.plugins.services.agent_loadbalancer.drivers.haproxy import cfg
from quantum.tests import base
class TestHaproxyCfg(testtools.TestCase): class TestHaproxyCfg(base.BaseTestCase):
def test_save_config(self): def test_save_config(self):
with contextlib.nested( with contextlib.nested(
mock.patch('quantum.plugins.services.agent_loadbalancer.' mock.patch('quantum.plugins.services.agent_loadbalancer.'

View File

@ -18,15 +18,15 @@
import contextlib import contextlib
import mock import mock
import testtools
from quantum.common import exceptions from quantum.common import exceptions
from quantum.plugins.services.agent_loadbalancer.drivers.haproxy import ( from quantum.plugins.services.agent_loadbalancer.drivers.haproxy import (
namespace_driver namespace_driver
) )
from quantum.tests import base
class TestHaproxyNSDriver(testtools.TestCase): class TestHaproxyNSDriver(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestHaproxyNSDriver, self).setUp() super(TestHaproxyNSDriver, self).setUp()

View File

@ -18,12 +18,12 @@
# @author: Mark McClain, DreamHost # @author: Mark McClain, DreamHost
import mock import mock
import testtools
from quantum import context from quantum import context
from quantum import manager from quantum import manager
from quantum.plugins.common import constants from quantum.plugins.common import constants
from quantum.plugins.services.agent_loadbalancer import plugin from quantum.plugins.services.agent_loadbalancer import plugin
from quantum.tests import base
from quantum.tests.unit.db.loadbalancer import test_db_loadbalancer from quantum.tests.unit.db.loadbalancer import test_db_loadbalancer
@ -171,7 +171,7 @@ class TestLoadBalancerCallbacks(TestLoadBalancerPluginBase):
) )
class TestLoadBalancerAgentApi(testtools.TestCase): class TestLoadBalancerAgentApi(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestLoadBalancerAgentApi, self).setUp() super(TestLoadBalancerAgentApi, self).setUp()
self.addCleanup(mock.patch.stopall) self.addCleanup(mock.patch.stopall)

View File

@ -15,9 +15,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import testtools
from quantum.agent.common import config from quantum.agent.common import config
from quantum.tests import base
def test_setup_conf(): def test_setup_conf():
@ -25,7 +24,7 @@ def test_setup_conf():
assert conf.state_path.endswith('/var/lib/quantum') assert conf.state_path.endswith('/var/lib/quantum')
class TestRootHelper(testtools.TestCase): class TestRootHelper(base.BaseTestCase):
def test_agent_root_helper(self): def test_agent_root_helper(self):
conf = config.setup_conf() conf = config.setup_conf()

View File

@ -17,12 +17,12 @@
import fixtures import fixtures
import mock import mock
import testtools
from quantum.agent.linux import utils from quantum.agent.linux import utils
from quantum.tests import base
class AgentUtilsExecuteTest(testtools.TestCase): class AgentUtilsExecuteTest(base.BaseTestCase):
def setUp(self): def setUp(self):
super(AgentUtilsExecuteTest, self).setUp() super(AgentUtilsExecuteTest, self).setUp()
self.root_helper = "echo" self.root_helper = "echo"
@ -63,7 +63,7 @@ class AgentUtilsExecuteTest(testtools.TestCase):
self.assertEqual(result, "%s\n" % self.test_file) self.assertEqual(result, "%s\n" % self.test_file)
class AgentUtilsGetInterfaceMAC(testtools.TestCase): class AgentUtilsGetInterfaceMAC(base.BaseTestCase):
def test_get_interface_mac(self): def test_get_interface_mac(self):
expect_val = '01:02:03:04:05:06' expect_val = '01:02:03:04:05:06'
with mock.patch('fcntl.ioctl') as ioctl: with mock.patch('fcntl.ioctl') as ioctl:
@ -74,7 +74,7 @@ class AgentUtilsGetInterfaceMAC(testtools.TestCase):
self.assertEqual(actual_val, expect_val) self.assertEqual(actual_val, expect_val)
class AgentUtilsReplaceFile(testtools.TestCase): class AgentUtilsReplaceFile(base.BaseTestCase):
def test_replace_file(self): def test_replace_file(self):
# make file to replace # make file to replace
with mock.patch('tempfile.NamedTemporaryFile') as ntf: with mock.patch('tempfile.NamedTemporaryFile') as ntf:

View File

@ -17,18 +17,18 @@
import mock import mock
from oslo.config import cfg from oslo.config import cfg
import testtools
from quantum.agent import netns_cleanup_util as util from quantum.agent import netns_cleanup_util as util
from quantum.tests import base
class TestNullDelegate(testtools.TestCase): class TestNullDelegate(base.BaseTestCase):
def test_getattribute(self): def test_getattribute(self):
null_delegate = util.NullDelegate() null_delegate = util.NullDelegate()
self.assertIsNone(null_delegate.test()) self.assertIsNone(null_delegate.test())
class TestNetnsCleanup(testtools.TestCase): class TestNetnsCleanup(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestNetnsCleanup, self).setUp() super(TestNetnsCleanup, self).setUp()
self.addCleanup(cfg.CONF.reset) self.addCleanup(cfg.CONF.reset)

View File

@ -19,15 +19,15 @@ import contextlib
import itertools import itertools
import mock import mock
from oslo.config import cfg from oslo.config import cfg
import testtools
from quantum.agent.linux import ip_lib from quantum.agent.linux import ip_lib
from quantum.agent.linux import ovs_lib from quantum.agent.linux import ovs_lib
from quantum.agent import ovs_cleanup_util as util from quantum.agent import ovs_cleanup_util as util
from quantum.openstack.common import uuidutils from quantum.openstack.common import uuidutils
from quantum.tests import base
class TestOVSCleanup(testtools.TestCase): class TestOVSCleanup(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestOVSCleanup, self).setUp() super(TestOVSCleanup, self).setUp()
self.addCleanup(cfg.CONF.reset) self.addCleanup(cfg.CONF.reset)

View File

@ -17,13 +17,13 @@
import mock import mock
from oslo.config import cfg from oslo.config import cfg
import testtools
from quantum.agent import rpc from quantum.agent import rpc
from quantum.openstack.common import context from quantum.openstack.common import context
from quantum.tests import base
class AgentRPCPluginApi(testtools.TestCase): class AgentRPCPluginApi(base.BaseTestCase):
def _test_rpc_call(self, method): def _test_rpc_call(self, method):
agent = rpc.PluginApi('fake_topic') agent = rpc.PluginApi('fake_topic')
ctxt = context.RequestContext('fake_user', 'fake_project') ctxt = context.RequestContext('fake_user', 'fake_project')
@ -47,7 +47,7 @@ class AgentRPCPluginApi(testtools.TestCase):
self._test_rpc_call('tunnel_sync') self._test_rpc_call('tunnel_sync')
class AgentRPCMethods(testtools.TestCase): class AgentRPCMethods(base.BaseTestCase):
def test_create_consumers(self): def test_create_consumers(self):
dispatcher = mock.Mock() dispatcher = mock.Mock()
expected = [ expected = [

View File

@ -18,18 +18,18 @@
# @author: Zhongyue Luo, Intel Corporation. # @author: Zhongyue Luo, Intel Corporation.
# #
import testtools
from testtools import matchers from testtools import matchers
from webob import exc from webob import exc
from quantum.api import api_common as common from quantum.api import api_common as common
from quantum.tests import base
class FakeController(common.QuantumController): class FakeController(common.QuantumController):
_resource_name = 'fake' _resource_name = 'fake'
class APICommonTestCase(testtools.TestCase): class APICommonTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(APICommonTestCase, self).setUp() super(APICommonTestCase, self).setUp()
self.controller = FakeController(None) self.controller = FakeController(None)

View File

@ -20,7 +20,6 @@ import urlparse
import mock import mock
from oslo.config import cfg from oslo.config import cfg
import testtools
from testtools import matchers from testtools import matchers
import webob import webob
from webob import exc from webob import exc
@ -29,7 +28,7 @@ import webtest
from quantum.api import api_common from quantum.api import api_common
from quantum.api.extensions import PluginAwareExtensionManager from quantum.api.extensions import PluginAwareExtensionManager
from quantum.api.v2 import attributes from quantum.api.v2 import attributes
from quantum.api.v2 import base from quantum.api.v2 import base as v2_base
from quantum.api.v2 import router from quantum.api.v2 import router
from quantum.common import config from quantum.common import config
from quantum.common import constants from quantum.common import constants
@ -38,6 +37,7 @@ from quantum import context
from quantum.manager import QuantumManager from quantum.manager import QuantumManager
from quantum.openstack.common.notifier import api as notifer_api from quantum.openstack.common.notifier import api as notifer_api
from quantum.openstack.common import uuidutils from quantum.openstack.common import uuidutils
from quantum.tests import base
from quantum.tests.unit import testlib_api from quantum.tests.unit import testlib_api
from quantum import wsgi from quantum import wsgi
@ -68,7 +68,7 @@ def _get_path(resource, id=None, action=None, fmt=None):
return path return path
class ResourceIndexTestCase(testtools.TestCase): class ResourceIndexTestCase(base.BaseTestCase):
def test_index_json(self): def test_index_json(self):
index = webtest.TestApp(router.Index({'foo': 'bar'})) index = webtest.TestApp(router.Index({'foo': 'bar'}))
res = index.get('') res = index.get('')
@ -93,7 +93,7 @@ class ResourceIndexTestCase(testtools.TestCase):
self.assertTrue(link['rel'] == 'self') self.assertTrue(link['rel'] == 'self')
class APIv2TestBase(testtools.TestCase): class APIv2TestBase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(APIv2TestBase, self).setUp() super(APIv2TestBase, self).setUp()
@ -1105,7 +1105,7 @@ class JSONV2TestCase(APIv2TestBase, testlib_api.WebTestCase):
self.assertEqual(res.status_int, 400) self.assertEqual(res.status_int, 400)
class SubresourceTest(testtools.TestCase): class SubresourceTest(base.BaseTestCase):
def setUp(self): def setUp(self):
super(SubresourceTest, self).setUp() super(SubresourceTest, self).setUp()
@ -1206,12 +1206,12 @@ class XMLV2TestCase(JSONV2TestCase):
fmt = 'xml' fmt = 'xml'
class V2Views(testtools.TestCase): class V2Views(base.BaseTestCase):
def _view(self, keys, collection, resource): def _view(self, keys, collection, resource):
data = dict((key, 'value') for key in keys) data = dict((key, 'value') for key in keys)
data['fake'] = 'value' data['fake'] = 'value'
attr_info = attributes.RESOURCE_ATTRIBUTE_MAP[collection] attr_info = attributes.RESOURCE_ATTRIBUTE_MAP[collection]
controller = base.Controller(None, collection, resource, attr_info) controller = v2_base.Controller(None, collection, resource, attr_info)
res = controller._view(data) res = controller._view(data)
self.assertTrue('fake' not in res) self.assertTrue('fake' not in res)
for key in keys: for key in keys:
@ -1329,7 +1329,7 @@ class QuotaTest(APIv2TestBase):
self.assertEqual(res.status_int, exc.HTTPCreated.code) self.assertEqual(res.status_int, exc.HTTPCreated.code)
class ExtensionTestCase(testtools.TestCase): class ExtensionTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(ExtensionTestCase, self).setUp() super(ExtensionTestCase, self).setUp()
plugin = 'quantum.quantum_plugin_base_v2.QuantumPluginBaseV2' plugin = 'quantum.quantum_plugin_base_v2.QuantumPluginBaseV2'
@ -1419,7 +1419,7 @@ class TestSubresourcePlugin():
return return
class ListArgsTestCase(testtools.TestCase): class ListArgsTestCase(base.BaseTestCase):
def test_list_args(self): def test_list_args(self):
path = '/?fields=4&foo=3&fields=2&bar=1' path = '/?fields=4&foo=3&fields=2&bar=1'
request = webob.Request.blank(path) request = webob.Request.blank(path)
@ -1433,7 +1433,7 @@ class ListArgsTestCase(testtools.TestCase):
self.assertEqual([], api_common.list_args(request, 'fields')) self.assertEqual([], api_common.list_args(request, 'fields'))
class FiltersTestCase(testtools.TestCase): class FiltersTestCase(base.BaseTestCase):
def test_all_skip_args(self): def test_all_skip_args(self):
path = '/?fields=4&fields=3&fields=2&fields=1' path = '/?fields=4&fields=3&fields=2&fields=1'
request = webob.Request.blank(path) request = webob.Request.blank(path)
@ -1481,7 +1481,7 @@ class FiltersTestCase(testtools.TestCase):
self.assertEqual(actual_val, expect_val) self.assertEqual(actual_val, expect_val)
class CreateResourceTestCase(testtools.TestCase): class CreateResourceTestCase(base.BaseTestCase):
def test_resource_creation(self): def test_resource_creation(self):
resource = base.create_resource('fakes', 'fake', None, {}) resource = v2_base.create_resource('fakes', 'fake', None, {})
self.assertIsInstance(resource, webob.dec.wsgify) self.assertIsInstance(resource, webob.dec.wsgify)

View File

@ -19,17 +19,17 @@
# #
import mock import mock
import testtools
from webob import exc from webob import exc
import webtest import webtest
from quantum.api.v2 import resource as wsgi_resource from quantum.api.v2 import resource as wsgi_resource
from quantum.common import exceptions as q_exc from quantum.common import exceptions as q_exc
from quantum import context from quantum import context
from quantum.tests import base
from quantum import wsgi from quantum import wsgi
class RequestTestCase(testtools.TestCase): class RequestTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(RequestTestCase, self).setUp() super(RequestTestCase, self).setUp()
self.req = wsgi_resource.Request({'foo': 'bar'}) self.req = wsgi_resource.Request({'foo': 'bar'})
@ -99,7 +99,7 @@ class RequestTestCase(testtools.TestCase):
self.assertTrue(self.req.context.is_admin) self.assertTrue(self.req.context.is_admin)
class ResourceTestCase(testtools.TestCase): class ResourceTestCase(base.BaseTestCase):
def test_unmapped_quantum_error(self): def test_unmapped_quantum_error(self):
controller = mock.MagicMock() controller = mock.MagicMock()
controller.test.side_effect = q_exc.QuantumException() controller.test.side_effect = q_exc.QuantumException()

View File

@ -19,9 +19,10 @@ import testtools
from quantum.api.v2 import attributes from quantum.api.v2 import attributes
from quantum.common import exceptions as q_exc from quantum.common import exceptions as q_exc
from quantum.tests import base
class TestAttributes(testtools.TestCase): class TestAttributes(base.BaseTestCase):
def _construct_dict_and_constraints(self): def _construct_dict_and_constraints(self):
""" Constructs a test dictionary and a definition of constraints. """ Constructs a test dictionary and a definition of constraints.
@ -537,7 +538,7 @@ class TestAttributes(testtools.TestCase):
self.assertIsNone(msg) self.assertIsNone(msg)
class TestConvertToBoolean(testtools.TestCase): class TestConvertToBoolean(base.BaseTestCase):
def test_convert_to_boolean_bool(self): def test_convert_to_boolean_bool(self):
self.assertIs(attributes.convert_to_boolean(True), True) self.assertIs(attributes.convert_to_boolean(True), True)
@ -562,7 +563,7 @@ class TestConvertToBoolean(testtools.TestCase):
'7') '7')
class TestConvertToInt(testtools.TestCase): class TestConvertToInt(base.BaseTestCase):
def test_convert_to_int_int(self): def test_convert_to_int_int(self):
self.assertEqual(attributes.convert_to_int(-1), -1) self.assertEqual(attributes.convert_to_int(-1), -1)
@ -596,7 +597,7 @@ class TestConvertToInt(testtools.TestCase):
value, attributes.convert_none_to_empty_list(value)) value, attributes.convert_none_to_empty_list(value))
class TestConvertKvp(testtools.TestCase): class TestConvertKvp(base.BaseTestCase):
def test_convert_kvp_list_to_dict_succeeds_for_missing_values(self): def test_convert_kvp_list_to_dict_succeeds_for_missing_values(self):
result = attributes.convert_kvp_list_to_dict(['True']) result = attributes.convert_kvp_list_to_dict(['True'])
@ -628,7 +629,7 @@ class TestConvertKvp(testtools.TestCase):
self.assertEqual(['a', 'a=a'], result) self.assertEqual(['a', 'a=a'], result)
class TestConvertToList(testtools.TestCase): class TestConvertToList(base.BaseTestCase):
def test_convert_to_empty_list(self): def test_convert_to_empty_list(self):
for item in (None, [], (), {}): for item in (None, [], (), {}):

View File

@ -1,10 +1,27 @@
import testtools # vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 OpenStack LLC
# All Rights Reserved.
#
# 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.
import webob import webob
from quantum import auth from quantum import auth
from quantum.tests import base
class QuantumKeystoneContextTestCase(testtools.TestCase): class QuantumKeystoneContextTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(QuantumKeystoneContextTestCase, self).setUp() super(QuantumKeystoneContextTestCase, self).setUp()

View File

@ -15,9 +15,10 @@
import testtools import testtools
from quantum.common import utils from quantum.common import utils
from quantum.tests import base
class TestParseMappings(testtools.TestCase): class TestParseMappings(base.BaseTestCase):
def parse(self, mapping_list, unique_values=True): def parse(self, mapping_list, unique_values=True):
return utils.parse_mappings(mapping_list, unique_values) return utils.parse_mappings(mapping_list, unique_values)

View File

@ -14,14 +14,14 @@
# limitations under the License. # limitations under the License.
import os import os
import testtools
from oslo.config import cfg from oslo.config import cfg
from quantum.common import config from quantum.common import config
from quantum.tests import base
class ConfigurationTest(testtools.TestCase): class ConfigurationTest(base.BaseTestCase):
def test_defaults(self): def test_defaults(self):
self.assertEqual('0.0.0.0', cfg.CONF.bind_host) self.assertEqual('0.0.0.0', cfg.CONF.bind_host)

View File

@ -18,12 +18,12 @@
import fixtures import fixtures
import mock import mock
from oslo.config import cfg from oslo.config import cfg
import testtools
import quantum.db.api as db import quantum.db.api as db
from quantum.tests import base
class DBTestCase(testtools.TestCase): class DBTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(DBTestCase, self).setUp() super(DBTestCase, self).setUp()
cfg.CONF.set_override('sql_max_retries', 1, 'DATABASE') cfg.CONF.set_override('sql_max_retries', 1, 'DATABASE')

View File

@ -20,13 +20,13 @@
import sys import sys
import mock import mock
import testtools
from quantum.db import migration from quantum.db import migration
from quantum.db.migration import cli from quantum.db.migration import cli
from quantum.tests import base
class TestDbMigration(testtools.TestCase): class TestDbMigration(base.BaseTestCase):
def test_should_run_plugin_in_list(self): def test_should_run_plugin_in_list(self):
self.assertTrue(migration.should_run('foo', ['foo', 'bar'])) self.assertTrue(migration.should_run('foo', ['foo', 'bar']))
self.assertFalse(migration.should_run('foo', ['bar'])) self.assertFalse(migration.should_run('foo', ['bar']))
@ -35,7 +35,7 @@ class TestDbMigration(testtools.TestCase):
self.assertTrue(migration.should_run('foo', ['*'])) self.assertTrue(migration.should_run('foo', ['*']))
class TestCli(testtools.TestCase): class TestCli(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestCli, self).setUp() super(TestCli, self).setUp()
self.do_alembic_cmd_p = mock.patch.object(cli, 'do_alembic_command') self.do_alembic_cmd_p = mock.patch.object(cli, 'do_alembic_command')

View File

@ -43,6 +43,7 @@ from quantum.db import db_base_plugin_v2
from quantum.db import models_v2 from quantum.db import models_v2
from quantum.manager import QuantumManager from quantum.manager import QuantumManager
from quantum.openstack.common import timeutils from quantum.openstack.common import timeutils
from quantum.tests import base
from quantum.tests.unit import test_extensions from quantum.tests.unit import test_extensions
from quantum.tests.unit import testlib_api from quantum.tests.unit import testlib_api
@ -80,6 +81,7 @@ class QuantumDbPluginV2TestCase(testlib_api.WebTestCase):
def setUp(self, plugin=None, service_plugins=None): def setUp(self, plugin=None, service_plugins=None):
super(QuantumDbPluginV2TestCase, self).setUp() super(QuantumDbPluginV2TestCase, self).setUp()
# NOTE(jkoelker) for a 'pluggable' framework, Quantum sure # NOTE(jkoelker) for a 'pluggable' framework, Quantum sure
# doesn't like when the plugin changes ;) # doesn't like when the plugin changes ;)
db._ENGINE = None db._ENGINE = None
@ -3431,7 +3433,7 @@ class TestSubnetsV2(QuantumDbPluginV2TestCase):
self.assertEqual(res.status_int, 204) self.assertEqual(res.status_int, 204)
class DbModelTestCase(testtools.TestCase): class DbModelTestCase(base.BaseTestCase):
""" DB model tests """ """ DB model tests """
def test_repr(self): def test_repr(self):
""" testing the string representation of 'model' classes """ """ testing the string representation of 'model' classes """

View File

@ -14,12 +14,12 @@
# limitations under the License. # limitations under the License.
import mock import mock
import testtools
from quantum.db import dhcp_rpc_base from quantum.db import dhcp_rpc_base
from quantum.tests import base
class TestDhcpRpcCallackMixin(testtools.TestCase): class TestDhcpRpcCallackMixin(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestDhcpRpcCallackMixin, self).setUp() super(TestDhcpRpcCallackMixin, self).setUp()

View File

@ -19,12 +19,12 @@ import socket
import mock import mock
from oslo.config import cfg from oslo.config import cfg
import testtools
from quantum.agent.common import config from quantum.agent.common import config
from quantum.agent.linux import interface from quantum.agent.linux import interface
from quantum.debug import commands from quantum.debug import commands
from quantum.debug.debug_agent import DEVICE_OWNER_PROBE, QuantumDebugAgent from quantum.debug.debug_agent import DEVICE_OWNER_PROBE, QuantumDebugAgent
from quantum.tests import base
class MyApp(object): class MyApp(object):
@ -32,7 +32,7 @@ class MyApp(object):
self.stdout = _stdout self.stdout = _stdout
class TestDebugCommands(testtools.TestCase): class TestDebugCommands(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestDebugCommands, self).setUp() super(TestDebugCommands, self).setUp()
cfg.CONF.register_opts(interface.OPTS) cfg.CONF.register_opts(interface.OPTS)

View File

@ -14,6 +14,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import os import os
import socket import socket
import sys import sys
@ -32,6 +33,7 @@ from quantum.agent.linux import interface
from quantum.common import constants from quantum.common import constants
from quantum.common import exceptions from quantum.common import exceptions
from quantum.openstack.common import jsonutils from quantum.openstack.common import jsonutils
from quantum.tests import base
ROOTDIR = os.path.dirname(os.path.dirname(__file__)) ROOTDIR = os.path.dirname(os.path.dirname(__file__))
@ -108,7 +110,7 @@ fake_down_network = FakeModel('12345678-dddd-dddd-1234567890ab',
ports=[]) ports=[])
class TestDhcpAgent(testtools.TestCase): class TestDhcpAgent(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestDhcpAgent, self).setUp() super(TestDhcpAgent, self).setUp()
cfg.CONF.register_opts(dhcp_agent.DeviceManager.OPTS) cfg.CONF.register_opts(dhcp_agent.DeviceManager.OPTS)
@ -323,7 +325,7 @@ class TestDhcpAgent(testtools.TestCase):
self.assertFalse(dhcp.needs_resync) self.assertFalse(dhcp.needs_resync)
class TestDhcpAgentEventHandler(testtools.TestCase): class TestDhcpAgentEventHandler(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestDhcpAgentEventHandler, self).setUp() super(TestDhcpAgentEventHandler, self).setUp()
cfg.CONF.register_opts(dhcp_agent.DeviceManager.OPTS) cfg.CONF.register_opts(dhcp_agent.DeviceManager.OPTS)
@ -638,7 +640,7 @@ class TestDhcpAgentEventHandler(testtools.TestCase):
self.assertEqual(self.call_driver.call_count, 0) self.assertEqual(self.call_driver.call_count, 0)
class TestDhcpPluginApiProxy(testtools.TestCase): class TestDhcpPluginApiProxy(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestDhcpPluginApiProxy, self).setUp() super(TestDhcpPluginApiProxy, self).setUp()
self.proxy = dhcp_agent.DhcpPluginApi('foo', {}) self.proxy = dhcp_agent.DhcpPluginApi('foo', {})
@ -707,7 +709,7 @@ class TestDhcpPluginApiProxy(testtools.TestCase):
host='foo') host='foo')
class TestNetworkCache(testtools.TestCase): class TestNetworkCache(base.BaseTestCase):
def test_put_network(self): def test_put_network(self):
nc = dhcp_agent.NetworkCache() nc = dhcp_agent.NetworkCache()
nc.put(fake_network) nc.put(fake_network)
@ -815,7 +817,7 @@ class TestNetworkCache(testtools.TestCase):
self.assertEqual(nc.get_port_by_id(fake_port1.id), fake_port1) self.assertEqual(nc.get_port_by_id(fake_port1.id), fake_port1)
class TestDeviceManager(testtools.TestCase): class TestDeviceManager(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestDeviceManager, self).setUp() super(TestDeviceManager, self).setUp()
cfg.CONF.register_opts(dhcp_agent.DeviceManager.OPTS) cfg.CONF.register_opts(dhcp_agent.DeviceManager.OPTS)
@ -1010,7 +1012,7 @@ class TestDeviceManager(testtools.TestCase):
self.assertEqual(dh.get_device_id(fake_network), expected) self.assertEqual(dh.get_device_id(fake_network), expected)
class TestDhcpLeaseRelay(testtools.TestCase): class TestDhcpLeaseRelay(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestDhcpLeaseRelay, self).setUp() super(TestDhcpLeaseRelay, self).setUp()
cfg.CONF.register_opts(dhcp_agent.DhcpLeaseRelay.OPTS) cfg.CONF.register_opts(dhcp_agent.DhcpLeaseRelay.OPTS)
@ -1135,7 +1137,7 @@ class TestDhcpLeaseRelay(testtools.TestCase):
relay._handler)]) relay._handler)])
class TestDictModel(testtools.TestCase): class TestDictModel(base.BaseTestCase):
def test_basic_dict(self): def test_basic_dict(self):
d = dict(a=1, b=2) d = dict(a=1, b=2)

View File

@ -20,7 +20,6 @@ Unit tests for extension extended attribute
""" """
from oslo.config import cfg from oslo.config import cfg
import testtools
import webob.exc as webexc import webob.exc as webexc
import quantum import quantum
@ -29,6 +28,7 @@ from quantum.common import config
from quantum import manager from quantum import manager
from quantum.plugins.common import constants from quantum.plugins.common import constants
from quantum.plugins.openvswitch import ovs_quantum_plugin from quantum.plugins.openvswitch import ovs_quantum_plugin
from quantum.tests import base
from quantum.tests.unit.extensions import extendedattribute as extattr from quantum.tests.unit.extensions import extendedattribute as extattr
from quantum.tests.unit import test_api_v2 from quantum.tests.unit import test_api_v2
from quantum.tests.unit import testlib_api from quantum.tests.unit import testlib_api
@ -66,7 +66,7 @@ class ExtensionExtendedAttributeTestPlugin(
return self.objh[id] return self.objh[id]
class ExtensionExtendedAttributeTestCase(testtools.TestCase): class ExtensionExtendedAttributeTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(ExtensionExtendedAttributeTestCase, self).setUp() super(ExtensionExtendedAttributeTestCase, self).setUp()
plugin = ( plugin = (

View File

@ -18,7 +18,6 @@
import os import os
import routes import routes
import testtools
import webob import webob
import webtest import webtest
@ -28,6 +27,7 @@ from quantum.db import db_base_plugin_v2
from quantum.openstack.common import jsonutils from quantum.openstack.common import jsonutils
from quantum.openstack.common import log as logging from quantum.openstack.common import log as logging
from quantum.plugins.common import constants from quantum.plugins.common import constants
from quantum.tests import base
from quantum.tests.unit import extension_stubs as ext_stubs from quantum.tests.unit import extension_stubs as ext_stubs
import quantum.tests.unit.extensions import quantum.tests.unit.extensions
from quantum.tests.unit import testlib_api from quantum.tests.unit import testlib_api
@ -65,7 +65,7 @@ class FakePluginWithExtension(db_base_plugin_v2.QuantumDbPluginV2):
self._log("method_to_support_foxnsox_extension", context) self._log("method_to_support_foxnsox_extension", context)
class ResourceExtensionTest(testtools.TestCase): class ResourceExtensionTest(base.BaseTestCase):
class ResourceExtensionController(wsgi.Controller): class ResourceExtensionController(wsgi.Controller):
@ -308,7 +308,7 @@ class ResourceExtensionTest(testtools.TestCase):
self.assertEqual(404, response.status_int) self.assertEqual(404, response.status_int)
class ActionExtensionTest(testtools.TestCase): class ActionExtensionTest(base.BaseTestCase):
def setUp(self): def setUp(self):
super(ActionExtensionTest, self).setUp() super(ActionExtensionTest, self).setUp()
@ -355,7 +355,7 @@ class ActionExtensionTest(testtools.TestCase):
self.assertEqual(404, response.status_int) self.assertEqual(404, response.status_int)
class RequestExtensionTest(testtools.TestCase): class RequestExtensionTest(base.BaseTestCase):
def test_headers_can_be_extended(self): def test_headers_can_be_extended(self):
def extend_headers(req, res): def extend_headers(req, res):
@ -422,7 +422,7 @@ class RequestExtensionTest(testtools.TestCase):
return _setup_extensions_test_app(manager) return _setup_extensions_test_app(manager)
class ExtensionManagerTest(testtools.TestCase): class ExtensionManagerTest(base.BaseTestCase):
def test_invalid_extensions_are_not_registered(self): def test_invalid_extensions_are_not_registered(self):
@ -442,7 +442,7 @@ class ExtensionManagerTest(testtools.TestCase):
self.assertFalse('invalid_extension' in ext_mgr.extensions) self.assertFalse('invalid_extension' in ext_mgr.extensions)
class PluginAwareExtensionManagerTest(testtools.TestCase): class PluginAwareExtensionManagerTest(base.BaseTestCase):
def test_unsupported_extensions_are_not_loaded(self): def test_unsupported_extensions_are_not_loaded(self):
stub_plugin = ext_stubs.StubPlugin(supported_extensions=["e1", "e3"]) stub_plugin = ext_stubs.StubPlugin(supported_extensions=["e1", "e3"])

View File

@ -17,10 +17,10 @@
import mock import mock
from mock import call from mock import call
import testtools
from quantum.agent.linux.iptables_firewall import IptablesFirewallDriver from quantum.agent.linux.iptables_firewall import IptablesFirewallDriver
from quantum.tests.unit import test_api_v2 from quantum.tests.unit import test_api_v2
from quantum.tests import base
_uuid = test_api_v2._uuid _uuid = test_api_v2._uuid
FAKE_PREFIX = {'IPv4': '10.0.0.0/24', FAKE_PREFIX = {'IPv4': '10.0.0.0/24',
@ -29,7 +29,7 @@ FAKE_IP = {'IPv4': '10.0.0.1',
'IPv6': 'fe80::1'} 'IPv6': 'fe80::1'}
class IptablesFirewallTestCase(testtools.TestCase): class IptablesFirewallTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(IptablesFirewallTestCase, self).setUp() super(IptablesFirewallTestCase, self).setUp()
self.utils_exec_p = mock.patch( self.utils_exec_p = mock.patch(

View File

@ -21,12 +21,12 @@ import inspect
import os import os
import mox import mox
import testtools
from quantum.agent.linux import iptables_manager from quantum.agent.linux import iptables_manager
from quantum.tests import base
class IptablesManagerStateFulTestCase(testtools.TestCase): class IptablesManagerStateFulTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(IptablesManagerStateFulTestCase, self).setUp() super(IptablesManagerStateFulTestCase, self).setUp()
@ -294,7 +294,7 @@ class IptablesManagerStateFulTestCase(testtools.TestCase):
self.mox.VerifyAll() self.mox.VerifyAll()
class IptablesManagerStateLessTestCase(testtools.TestCase): class IptablesManagerStateLessTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(IptablesManagerStateLessTestCase, self).setUp() super(IptablesManagerStateLessTestCase, self).setUp()

View File

@ -19,7 +19,6 @@ import copy
import mock import mock
from oslo.config import cfg from oslo.config import cfg
import testtools
from quantum.agent.common import config as agent_config from quantum.agent.common import config as agent_config
from quantum.agent import l3_agent from quantum.agent import l3_agent
@ -27,13 +26,14 @@ from quantum.agent.linux import interface
from quantum.common import config as base_config from quantum.common import config as base_config
from quantum.common import constants as l3_constants from quantum.common import constants as l3_constants
from quantum.openstack.common import uuidutils from quantum.openstack.common import uuidutils
from quantum.tests import base
_uuid = uuidutils.generate_uuid _uuid = uuidutils.generate_uuid
HOSTNAME = 'myhost' HOSTNAME = 'myhost'
class TestBasicRouterOperations(testtools.TestCase): class TestBasicRouterOperations(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestBasicRouterOperations, self).setUp() super(TestBasicRouterOperations, self).setUp()

View File

@ -45,6 +45,7 @@ from quantum.openstack.common import log as logging
from quantum.openstack.common.notifier import api as notifier_api from quantum.openstack.common.notifier import api as notifier_api
from quantum.openstack.common.notifier import test_notifier from quantum.openstack.common.notifier import test_notifier
from quantum.openstack.common import uuidutils from quantum.openstack.common import uuidutils
from quantum.tests import base
from quantum.tests.unit import test_api_v2 from quantum.tests.unit import test_api_v2
from quantum.tests.unit import test_db_plugin from quantum.tests.unit import test_db_plugin
from quantum.tests.unit import test_extensions from quantum.tests.unit import test_extensions

View File

@ -22,11 +22,12 @@ import mock
import testtools import testtools
from quantum.agent.linux import daemon from quantum.agent.linux import daemon
from quantum.tests import base
FAKE_FD = 8 FAKE_FD = 8
class TestPidfile(testtools.TestCase): class TestPidfile(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestPidfile, self).setUp() super(TestPidfile, self).setUp()
self.os_p = mock.patch.object(daemon, 'os') self.os_p = mock.patch.object(daemon, 'os')
@ -94,7 +95,7 @@ class TestPidfile(testtools.TestCase):
['cat', '/proc/34/cmdline'], 'sudo') ['cat', '/proc/34/cmdline'], 'sudo')
class TestDaemon(testtools.TestCase): class TestDaemon(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestDaemon, self).setUp() super(TestDaemon, self).setUp()
self.os_p = mock.patch.object(daemon, 'os') self.os_p = mock.patch.object(daemon, 'os')

View File

@ -20,11 +20,11 @@ import socket
import mock import mock
from oslo.config import cfg from oslo.config import cfg
import testtools
from quantum.agent.common import config from quantum.agent.common import config
from quantum.agent.linux import dhcp from quantum.agent.linux import dhcp
from quantum.openstack.common import jsonutils from quantum.openstack.common import jsonutils
from quantum.tests import base
class FakeIPAllocation: class FakeIPAllocation:
@ -134,7 +134,7 @@ class FakeV4NoGatewayNetwork:
ports = [FakePort1()] ports = [FakePort1()]
class TestDhcpBase(testtools.TestCase): class TestDhcpBase(base.BaseTestCase):
def test_base_abc_error(self): def test_base_abc_error(self):
self.assertRaises(TypeError, dhcp.DhcpBase, None) self.assertRaises(TypeError, dhcp.DhcpBase, None)
@ -179,7 +179,7 @@ class LocalChild(dhcp.DhcpLocalProcess):
self.called.append('spawn') self.called.append('spawn')
class TestBase(testtools.TestCase): class TestBase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestBase, self).setUp() super(TestBase, self).setUp()
root = os.path.dirname(os.path.dirname(__file__)) root = os.path.dirname(os.path.dirname(__file__))

View File

@ -17,12 +17,12 @@
# @author: Mark McClain, DreamHost # @author: Mark McClain, DreamHost
import mock import mock
import testtools
from quantum.agent.linux import external_process as ep from quantum.agent.linux import external_process as ep
from quantum.tests import base
class TestProcessManager(testtools.TestCase): class TestProcessManager(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestProcessManager, self).setUp() super(TestProcessManager, self).setUp()
self.execute_p = mock.patch('quantum.agent.linux.utils.execute') self.execute_p = mock.patch('quantum.agent.linux.utils.execute')

View File

@ -17,7 +17,6 @@
import mock import mock
from oslo.config import cfg from oslo.config import cfg
import testtools
from quantum.agent.common import config from quantum.agent.common import config
from quantum.agent.dhcp_agent import DeviceManager from quantum.agent.dhcp_agent import DeviceManager
@ -25,6 +24,7 @@ from quantum.agent.linux import interface
from quantum.agent.linux import ip_lib from quantum.agent.linux import ip_lib
from quantum.agent.linux import utils from quantum.agent.linux import utils
from quantum.extensions.flavor import (FLAVOR_NETWORK) from quantum.extensions.flavor import (FLAVOR_NETWORK)
from quantum.tests import base
class BaseChild(interface.LinuxInterfaceDriver): class BaseChild(interface.LinuxInterfaceDriver):
@ -57,7 +57,7 @@ class FakePort:
network_id = network.id network_id = network.id
class TestBase(testtools.TestCase): class TestBase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestBase, self).setUp() super(TestBase, self).setUp()
root_helper_opt = [ root_helper_opt = [

View File

@ -16,10 +16,10 @@
# under the License. # under the License.
import mock import mock
import testtools
from quantum.agent.linux import ip_lib from quantum.agent.linux import ip_lib
from quantum.common import exceptions from quantum.common import exceptions
from quantum.tests import base
NETNS_SAMPLE = [ NETNS_SAMPLE = [
'12345678-1234-5678-abcd-1234567890ab', '12345678-1234-5678-abcd-1234567890ab',
@ -97,7 +97,7 @@ SUBNET_SAMPLE2 = ("10.0.0.0/24 dev tap1d7888a7-10 scope link src 10.0.0.2\n"
"10.0.0.0/24 dev qr-23380d11-d2 scope link src 10.0.0.1") "10.0.0.0/24 dev qr-23380d11-d2 scope link src 10.0.0.1")
class TestSubProcessBase(testtools.TestCase): class TestSubProcessBase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestSubProcessBase, self).setUp() super(TestSubProcessBase, self).setUp()
self.execute_p = mock.patch('quantum.agent.linux.utils.execute') self.execute_p = mock.patch('quantum.agent.linux.utils.execute')
@ -149,7 +149,7 @@ class TestSubProcessBase(testtools.TestCase):
[], 'link', ('list',)) [], 'link', ('list',))
class TestIpWrapper(testtools.TestCase): class TestIpWrapper(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestIpWrapper, self).setUp() super(TestIpWrapper, self).setUp()
self.execute_p = mock.patch.object(ip_lib.IPWrapper, '_execute') self.execute_p = mock.patch.object(ip_lib.IPWrapper, '_execute')
@ -305,7 +305,7 @@ class TestIpWrapper(testtools.TestCase):
self.assertEqual(dev.mock_calls, []) self.assertEqual(dev.mock_calls, [])
class TestIPDevice(testtools.TestCase): class TestIPDevice(base.BaseTestCase):
def test_eq_same_name(self): def test_eq_same_name(self):
dev1 = ip_lib.IPDevice('tap0') dev1 = ip_lib.IPDevice('tap0')
dev2 = ip_lib.IPDevice('tap0') dev2 = ip_lib.IPDevice('tap0')
@ -334,7 +334,7 @@ class TestIPDevice(testtools.TestCase):
self.assertEqual(str(ip_lib.IPDevice('tap0')), 'tap0') self.assertEqual(str(ip_lib.IPDevice('tap0')), 'tap0')
class TestIPCommandBase(testtools.TestCase): class TestIPCommandBase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestIPCommandBase, self).setUp() super(TestIPCommandBase, self).setUp()
self.ip = mock.Mock() self.ip = mock.Mock()
@ -362,7 +362,7 @@ class TestIPCommandBase(testtools.TestCase):
[mock.call._as_root('o', 'foo', ('link', ), False)]) [mock.call._as_root('o', 'foo', ('link', ), False)])
class TestIPDeviceCommandBase(testtools.TestCase): class TestIPDeviceCommandBase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestIPDeviceCommandBase, self).setUp() super(TestIPDeviceCommandBase, self).setUp()
self.ip_dev = mock.Mock() self.ip_dev = mock.Mock()
@ -376,7 +376,7 @@ class TestIPDeviceCommandBase(testtools.TestCase):
self.assertEqual(self.ip_cmd.name, 'eth0') self.assertEqual(self.ip_cmd.name, 'eth0')
class TestIPCmdBase(testtools.TestCase): class TestIPCmdBase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestIPCmdBase, self).setUp() super(TestIPCmdBase, self).setUp()
self.parent = mock.Mock() self.parent = mock.Mock()
@ -654,7 +654,7 @@ class TestIpNetnsCommand(TestIPCmdBase):
root_helper='sudo', check_exit_code=True) root_helper='sudo', check_exit_code=True)
class TestDeviceExists(testtools.TestCase): class TestDeviceExists(base.BaseTestCase):
def test_device_exists(self): def test_device_exists(self):
with mock.patch.object(ip_lib.IPDevice, '_execute') as _execute: with mock.patch.object(ip_lib.IPDevice, '_execute') as _execute:
_execute.return_value = LINK_SAMPLE[1] _execute.return_value = LINK_SAMPLE[1]

View File

@ -18,7 +18,6 @@ import copy
import mock import mock
from oslo.config import cfg from oslo.config import cfg
import testtools
from webob import exc from webob import exc
import webtest import webtest
@ -29,6 +28,7 @@ from quantum.extensions import loadbalancer
from quantum import manager from quantum import manager
from quantum.openstack.common import uuidutils from quantum.openstack.common import uuidutils
from quantum.plugins.common import constants from quantum.plugins.common import constants
from quantum.tests import base
from quantum.tests.unit import test_api_v2 from quantum.tests.unit import test_api_v2
from quantum.tests.unit import test_extensions from quantum.tests.unit import test_extensions
from quantum.tests.unit import testlib_api from quantum.tests.unit import testlib_api

View File

@ -23,6 +23,7 @@ import testtools
import webob import webob
from quantum.agent.metadata import agent from quantum.agent.metadata import agent
from quantum.tests import base
class FakeConf(object): class FakeConf(object):
@ -37,7 +38,7 @@ class FakeConf(object):
metadata_proxy_shared_secret = 'secret' metadata_proxy_shared_secret = 'secret'
class TestMetadataProxyHandler(testtools.TestCase): class TestMetadataProxyHandler(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestMetadataProxyHandler, self).setUp() super(TestMetadataProxyHandler, self).setUp()
self.qclient_p = mock.patch('quantumclient.v2_0.client.Client') self.qclient_p = mock.patch('quantumclient.v2_0.client.Client')
@ -225,7 +226,7 @@ class TestMetadataProxyHandler(testtools.TestCase):
) )
class TestUnixDomainHttpProtocol(testtools.TestCase): class TestUnixDomainHttpProtocol(base.BaseTestCase):
def test_init_empty_client(self): def test_init_empty_client(self):
u = agent.UnixDomainHttpProtocol(mock.Mock(), '', mock.Mock()) u = agent.UnixDomainHttpProtocol(mock.Mock(), '', mock.Mock())
self.assertEqual(u.client_address, ('<local>', 0)) self.assertEqual(u.client_address, ('<local>', 0))
@ -235,7 +236,7 @@ class TestUnixDomainHttpProtocol(testtools.TestCase):
self.assertEqual(u.client_address, 'foo') self.assertEqual(u.client_address, 'foo')
class TestUnixDomainWSGIServer(testtools.TestCase): class TestUnixDomainWSGIServer(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestUnixDomainWSGIServer, self).setUp() super(TestUnixDomainWSGIServer, self).setUp()
self.eventlet_p = mock.patch.object(agent, 'eventlet') self.eventlet_p = mock.patch.object(agent, 'eventlet')
@ -274,7 +275,7 @@ class TestUnixDomainWSGIServer(testtools.TestCase):
self.assertTrue(len(logging.mock_calls)) self.assertTrue(len(logging.mock_calls))
class TestUnixDomainMetadataProxy(testtools.TestCase): class TestUnixDomainMetadataProxy(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestUnixDomainMetadataProxy, self).setUp() super(TestUnixDomainMetadataProxy, self).setUp()
self.cfg_p = mock.patch.object(agent, 'cfg') self.cfg_p = mock.patch.object(agent, 'cfg')

View File

@ -23,6 +23,7 @@ import testtools
import webob import webob
from quantum.agent.metadata import namespace_proxy as ns_proxy from quantum.agent.metadata import namespace_proxy as ns_proxy
from quantum.tests import base
class FakeConf(object): class FakeConf(object):
@ -37,7 +38,7 @@ class FakeConf(object):
metadata_proxy_shared_secret = 'secret' metadata_proxy_shared_secret = 'secret'
class TestUnixDomainHttpConnection(testtools.TestCase): class TestUnixDomainHttpConnection(base.BaseTestCase):
def test_connect(self): def test_connect(self):
with mock.patch.object(ns_proxy, 'cfg') as cfg: with mock.patch.object(ns_proxy, 'cfg') as cfg:
cfg.CONF.metadata_proxy_socket = '/the/path' cfg.CONF.metadata_proxy_socket = '/the/path'
@ -55,7 +56,7 @@ class TestUnixDomainHttpConnection(testtools.TestCase):
self.assertEqual(conn.timeout, 3) self.assertEqual(conn.timeout, 3)
class TestNetworkMetadataProxyHandler(testtools.TestCase): class TestNetworkMetadataProxyHandler(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestNetworkMetadataProxyHandler, self).setUp() super(TestNetworkMetadataProxyHandler, self).setUp()
self.log_p = mock.patch.object(ns_proxy, 'LOG') self.log_p = mock.patch.object(ns_proxy, 'LOG')
@ -231,7 +232,7 @@ class TestNetworkMetadataProxyHandler(testtools.TestCase):
) )
class TestProxyDaemon(testtools.TestCase): class TestProxyDaemon(base.BaseTestCase):
def test_init(self): def test_init(self):
with mock.patch('quantum.agent.linux.daemon.Pidfile') as pf: with mock.patch('quantum.agent.linux.daemon.Pidfile') as pf:
pd = ns_proxy.ProxyDaemon('pidfile', 9697, 'net_id', 'router_id') pd = ns_proxy.ProxyDaemon('pidfile', 9697, 'net_id', 'router_id')

View File

@ -23,7 +23,6 @@ import urllib2
import fixtures import fixtures
import mock import mock
import testtools
import quantum import quantum
from quantum.common import exceptions from quantum.common import exceptions
@ -31,9 +30,10 @@ from quantum import context
from quantum.openstack.common import importutils from quantum.openstack.common import importutils
from quantum.openstack.common import policy as common_policy from quantum.openstack.common import policy as common_policy
from quantum import policy from quantum import policy
from quantum.tests import base
class PolicyFileTestCase(testtools.TestCase): class PolicyFileTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(PolicyFileTestCase, self).setUp() super(PolicyFileTestCase, self).setUp()
policy.reset() policy.reset()
@ -66,7 +66,7 @@ class PolicyFileTestCase(testtools.TestCase):
self.target) self.target)
class PolicyTestCase(testtools.TestCase): class PolicyTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(PolicyTestCase, self).setUp() super(PolicyTestCase, self).setUp()
policy.reset() policy.reset()
@ -160,7 +160,7 @@ class PolicyTestCase(testtools.TestCase):
policy.enforce(admin_context, uppercase_action, self.target) policy.enforce(admin_context, uppercase_action, self.target)
class DefaultPolicyTestCase(testtools.TestCase): class DefaultPolicyTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(DefaultPolicyTestCase, self).setUp() super(DefaultPolicyTestCase, self).setUp()
@ -196,7 +196,7 @@ class DefaultPolicyTestCase(testtools.TestCase):
self.context, "example:noexist", {}) self.context, "example:noexist", {})
class QuantumPolicyTestCase(testtools.TestCase): class QuantumPolicyTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(QuantumPolicyTestCase, self).setUp() super(QuantumPolicyTestCase, self).setUp()

View File

@ -16,12 +16,12 @@
# under the License. # under the License.
import mock import mock
import testtools
from quantum import context from quantum import context
from quantum.tests import base
class TestQuantumContext(testtools.TestCase): class TestQuantumContext(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestQuantumContext, self).setUp() super(TestQuantumContext, self).setUp()

View File

@ -19,7 +19,6 @@ import os
import types import types
import fixtures import fixtures
import testtools
from oslo.config import cfg from oslo.config import cfg
@ -28,6 +27,7 @@ from quantum.common.test_lib import test_config
from quantum.manager import QuantumManager from quantum.manager import QuantumManager
from quantum.openstack.common import log as logging from quantum.openstack.common import log as logging
from quantum.plugins.common import constants from quantum.plugins.common import constants
from quantum.tests import base
from quantum.tests.unit import dummy_plugin from quantum.tests.unit import dummy_plugin
@ -41,7 +41,7 @@ def etcdir(*p):
return os.path.join(ETCDIR, *p) return os.path.join(ETCDIR, *p)
class QuantumManagerTestCase(testtools.TestCase): class QuantumManagerTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(QuantumManagerTestCase, self).setUp() super(QuantumManagerTestCase, self).setUp()

View File

@ -12,6 +12,7 @@ from quantum.db import api as db
from quantum import manager from quantum import manager
from quantum.plugins.linuxbridge.db import l2network_db_v2 from quantum.plugins.linuxbridge.db import l2network_db_v2
from quantum import quota from quantum import quota
from quantum.tests import base
from quantum.tests.unit import test_api_v2 from quantum.tests.unit import test_api_v2
from quantum.tests.unit import test_extensions from quantum.tests.unit import test_extensions
from quantum.tests.unit import testlib_api from quantum.tests.unit import testlib_api

View File

@ -17,14 +17,14 @@
import os import os
import mock import mock
import testtools
from quantum.common import utils from quantum.common import utils
from quantum.rootwrap import filters from quantum.rootwrap import filters
from quantum.rootwrap import wrapper from quantum.rootwrap import wrapper
from quantum.tests import base
class RootwrapTestCase(testtools.TestCase): class RootwrapTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(RootwrapTestCase, self).setUp() super(RootwrapTestCase, self).setUp()

View File

@ -34,6 +34,7 @@ from quantum.db import servicetype_db as st_db
from quantum.extensions import routedserviceinsertion as rsi from quantum.extensions import routedserviceinsertion as rsi
from quantum.extensions import routerservicetype as rst from quantum.extensions import routerservicetype as rst
from quantum.plugins.common import constants from quantum.plugins.common import constants
from quantum.tests import base
from quantum.tests.unit import test_api_v2 from quantum.tests.unit import test_api_v2
from quantum.tests.unit import testlib_api from quantum.tests.unit import testlib_api
from quantum import wsgi from quantum import wsgi
@ -154,7 +155,7 @@ class RouterServiceInsertionTestPlugin(
pass pass
class RouterServiceInsertionTestCase(testtools.TestCase): class RouterServiceInsertionTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(RouterServiceInsertionTestCase, self).setUp() super(RouterServiceInsertionTestCase, self).setUp()
plugin = ( plugin = (

View File

@ -21,7 +21,6 @@ import mock
from mock import call from mock import call
import mox import mox
from oslo.config import cfg from oslo.config import cfg
import testtools
from quantum.agent import firewall as firewall_base from quantum.agent import firewall as firewall_base
from quantum.agent.linux import iptables_manager from quantum.agent.linux import iptables_manager
@ -31,6 +30,7 @@ from quantum import context
from quantum.db import securitygroups_rpc_base as sg_db_rpc from quantum.db import securitygroups_rpc_base as sg_db_rpc
from quantum.extensions import securitygroup as ext_sg from quantum.extensions import securitygroup as ext_sg
from quantum.openstack.common.rpc import proxy from quantum.openstack.common.rpc import proxy
from quantum.tests import base
from quantum.tests.unit import test_extension_security_group as test_sg from quantum.tests.unit import test_extension_security_group as test_sg
from quantum.tests.unit import test_iptables_firewall as test_fw from quantum.tests.unit import test_iptables_firewall as test_fw
@ -370,7 +370,7 @@ class SGServerRpcCallBackMixinTestCaseXML(SGServerRpcCallBackMixinTestCase):
fmt = 'xml' fmt = 'xml'
class SGAgentRpcCallBackMixinTestCase(testtools.TestCase): class SGAgentRpcCallBackMixinTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(SGAgentRpcCallBackMixinTestCase, self).setUp() super(SGAgentRpcCallBackMixinTestCase, self).setUp()
self.rpc = sg_rpc.SecurityGroupAgentRpcCallbackMixin() self.rpc = sg_rpc.SecurityGroupAgentRpcCallbackMixin()
@ -394,7 +394,7 @@ class SGAgentRpcCallBackMixinTestCase(testtools.TestCase):
[call.security_groups_provider_updated()]) [call.security_groups_provider_updated()])
class SecurityGroupAgentRpcTestCase(testtools.TestCase): class SecurityGroupAgentRpcTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(SecurityGroupAgentRpcTestCase, self).setUp() super(SecurityGroupAgentRpcTestCase, self).setUp()
self.agent = sg_rpc.SecurityGroupAgentRpcMixin() self.agent = sg_rpc.SecurityGroupAgentRpcMixin()
@ -479,7 +479,7 @@ class FakeSGRpcApi(agent_rpc.PluginApi,
pass pass
class SecurityGroupServerRpcApiTestCase(testtools.TestCase): class SecurityGroupServerRpcApiTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(SecurityGroupServerRpcApiTestCase, self).setUp() super(SecurityGroupServerRpcApiTestCase, self).setUp()
self.rpc = FakeSGRpcApi('fake_topic') self.rpc = FakeSGRpcApi('fake_topic')
@ -502,7 +502,7 @@ class FakeSGNotifierAPI(proxy.RpcProxy,
pass pass
class SecurityGroupAgentRpcApiTestCase(testtools.TestCase): class SecurityGroupAgentRpcApiTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(SecurityGroupAgentRpcApiTestCase, self).setUp() super(SecurityGroupAgentRpcApiTestCase, self).setUp()
self.notifier = FakeSGNotifierAPI(topic='fake', self.notifier = FakeSGNotifierAPI(topic='fake',
@ -945,7 +945,7 @@ IPTABLES_FILTER_V6_EMPTY = """:%(bn)s-(%(chains)s) - [0:0]
FIREWALL_BASE_PACKAGE = 'quantum.agent.linux.iptables_firewall.' FIREWALL_BASE_PACKAGE = 'quantum.agent.linux.iptables_firewall.'
class TestSecurityGroupAgentWithIptables(testtools.TestCase): class TestSecurityGroupAgentWithIptables(base.BaseTestCase):
FIREWALL_DRIVER = FIREWALL_BASE_PACKAGE + 'IptablesFirewallDriver' FIREWALL_DRIVER = FIREWALL_BASE_PACKAGE + 'IptablesFirewallDriver'
PHYSDEV_INGRESS = 'physdev-out' PHYSDEV_INGRESS = 'physdev-out'
PHYSDEV_EGRESS = 'physdev-in' PHYSDEV_EGRESS = 'physdev-in'

View File

@ -22,7 +22,6 @@ import logging
import mock import mock
from oslo.config import cfg from oslo.config import cfg
import testtools
import webob.exc as webexc import webob.exc as webexc
import webtest import webtest
@ -34,6 +33,7 @@ from quantum.db import servicetype_db
from quantum.extensions import servicetype from quantum.extensions import servicetype
from quantum import manager from quantum import manager
from quantum.plugins.common import constants from quantum.plugins.common import constants
from quantum.tests import base
from quantum.tests.unit import dummy_plugin as dp from quantum.tests.unit import dummy_plugin as dp
from quantum.tests.unit import test_api_v2 from quantum.tests.unit import test_api_v2
from quantum.tests.unit import test_db_plugin from quantum.tests.unit import test_db_plugin

View File

@ -15,18 +15,17 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import socket
import mock import mock
import testtools import socket
from quantum.api.v2 import attributes from quantum.api.v2 import attributes
from quantum.common import constants from quantum.common import constants
from quantum.common import exceptions as exception from quantum.common import exceptions as exception
from quantum.tests import base
from quantum import wsgi from quantum import wsgi
class TestWSGIServer(testtools.TestCase): class TestWSGIServer(base.BaseTestCase):
"""WSGI server tests.""" """WSGI server tests."""
def test_start_random_port(self): def test_start_random_port(self):
@ -82,7 +81,7 @@ class TestWSGIServer(testtools.TestCase):
]) ])
class SerializerTest(testtools.TestCase): class SerializerTest(base.BaseTestCase):
def test_serialize_unknown_content_type(self): def test_serialize_unknown_content_type(self):
""" """
Test serialize verifies that exception InvalidContentType is raised Test serialize verifies that exception InvalidContentType is raised
@ -108,7 +107,7 @@ class SerializerTest(testtools.TestCase):
serializer.get_deserialize_handler, content_type) serializer.get_deserialize_handler, content_type)
class RequestDeserializerTest(testtools.TestCase): class RequestDeserializerTest(base.BaseTestCase):
def test_get_body_deserializer_unknown_content_type(self): def test_get_body_deserializer_unknown_content_type(self):
""" """
Test get body deserializer verifies Test get body deserializer verifies
@ -121,7 +120,7 @@ class RequestDeserializerTest(testtools.TestCase):
deserializer.get_body_deserializer, content_type) deserializer.get_body_deserializer, content_type)
class ResponseSerializerTest(testtools.TestCase): class ResponseSerializerTest(base.BaseTestCase):
def setUp(self): def setUp(self):
super(ResponseSerializerTest, self).setUp() super(ResponseSerializerTest, self).setUp()
@ -164,7 +163,7 @@ class ResponseSerializerTest(testtools.TestCase):
self.serializer.get_body_serializer, 'application/unknown') self.serializer.get_body_serializer, 'application/unknown')
class XMLDeserializerTest(testtools.TestCase): class XMLDeserializerTest(base.BaseTestCase):
def test_default_raise_Maiformed_Exception(self): def test_default_raise_Maiformed_Exception(self):
""" """
Test verifies that exception MalformedRequestBody is raised Test verifies that exception MalformedRequestBody is raised
@ -176,7 +175,7 @@ class XMLDeserializerTest(testtools.TestCase):
exception.MalformedRequestBody, deserializer.default, data_string) exception.MalformedRequestBody, deserializer.default, data_string)
class JSONDeserializerTest(testtools.TestCase): class JSONDeserializerTest(base.BaseTestCase):
def test_default_raise_Maiformed_Exception(self): def test_default_raise_Maiformed_Exception(self):
""" """
Test verifies JsonDeserializer.default Test verifies JsonDeserializer.default
@ -189,7 +188,7 @@ class JSONDeserializerTest(testtools.TestCase):
exception.MalformedRequestBody, deserializer.default, data_string) exception.MalformedRequestBody, deserializer.default, data_string)
class ResourceTest(testtools.TestCase): class ResourceTest(base.BaseTestCase):
def test_dispatch_unknown_controller_action(self): def test_dispatch_unknown_controller_action(self):
class Controller(object): class Controller(object):
def index(self, request, pants=None): def index(self, request, pants=None):
@ -262,7 +261,7 @@ class ResourceTest(testtools.TestCase):
self.assertEqual(400, result.status_int) self.assertEqual(400, result.status_int)
class XMLDictSerializerTest(testtools.TestCase): class XMLDictSerializerTest(base.BaseTestCase):
def test_xml(self): def test_xml(self):
NETWORK = {'network': {'test': None, NETWORK = {'network': {'test': None,
'tenant_id': 'test-tenant', 'tenant_id': 'test-tenant',

View File

@ -13,9 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import testtools
from quantum.api.v2 import attributes from quantum.api.v2 import attributes
from quantum.tests import base
from quantum import wsgi from quantum import wsgi
@ -35,7 +34,7 @@ def create_request(path, body, content_type, method='GET',
return req return req
class WebTestCase(testtools.TestCase): class WebTestCase(base.BaseTestCase):
fmt = 'json' fmt = 'json'
def setUp(self): def setUp(self):