Use oslotest instead of common test module

Module openstack.common.test is obsolete, so we should use
oslotest library instead of it.
Modified tests and common database code, new requirement added.

Change-Id: I853e548f11a4c3785eaf75124510a6d789536634
This commit is contained in:
Victor Sergeyev 2014-04-15 13:05:35 +03:00
parent f0609bcc5e
commit 64b71dbdbe
7 changed files with 21 additions and 21 deletions

View File

@ -18,12 +18,12 @@ import functools
import os
import fixtures
from oslotest import base as test_base
import six
from openstack.common.db.sqlalchemy import session
from openstack.common.db.sqlalchemy import utils
from openstack.common.fixture import lockutils
from openstack.common import test
class DbFixture(fixtures.Fixture):
@ -51,7 +51,7 @@ class DbFixture(fixtures.Fixture):
self.addCleanup(self.test.engine.dispose)
class DbTestCase(test.BaseTestCase):
class DbTestCase(test_base.BaseTestCase):
"""Base class for testing of DB code.
Using `DbFixture`. Intended to be the main database test case to use all

View File

@ -20,6 +20,7 @@ import os
import subprocess
import lockfile
from oslotest import base as test_base
from six import moves
from six.moves.urllib import parse
import sqlalchemy
@ -27,7 +28,6 @@ import sqlalchemy.exc
from openstack.common.db.sqlalchemy import utils
from openstack.common.gettextutils import _LE
from openstack.common import test
LOG = logging.getLogger(__name__)
@ -68,7 +68,7 @@ def _set_db_lock(lock_path=None, lock_prefix=None):
return decorator
class BaseMigrationTestCase(test.BaseTestCase):
class BaseMigrationTestCase(test_base.BaseTestCase):
"""Base class fort testing of migration utils."""
def __init__(self, *args, **kwargs):

View File

@ -11,11 +11,11 @@
# under the License.
import mock
from oslotest import base as test_base
from openstack.common.db.sqlalchemy.migration_cli import ext_alembic
from openstack.common.db.sqlalchemy.migration_cli import ext_migrate
from openstack.common.db.sqlalchemy.migration_cli import manager
from openstack.common import test
class MockWithCmp(mock.MagicMock):
@ -28,7 +28,7 @@ class MockWithCmp(mock.MagicMock):
@mock.patch(('openstack.common.db.sqlalchemy.migration_cli.'
'ext_alembic.alembic.command'))
class TestAlembicExtension(test.BaseTestCase):
class TestAlembicExtension(test_base.BaseTestCase):
def setUp(self):
self.migration_config = {'alembic_ini_path': '.',
@ -88,7 +88,7 @@ class TestAlembicExtension(test.BaseTestCase):
@mock.patch(('openstack.common.db.sqlalchemy.migration_cli.'
'ext_migrate.migration'))
class TestMigrateExtension(test.BaseTestCase):
class TestMigrateExtension(test_base.BaseTestCase):
def setUp(self):
self.migration_config = {'migration_repo_path': '.',
@ -147,7 +147,7 @@ class TestMigrateExtension(test.BaseTestCase):
init_version=self.migration_config['init_version'])
class TestMigrationManager(test.BaseTestCase):
class TestMigrationManager(test_base.BaseTestCase):
def setUp(self):
self.migration_config = {'alembic_ini_path': '.',
@ -188,7 +188,7 @@ class TestMigrationManager(test.BaseTestCase):
self.ext.obj.stamp.assert_called_once_with('stamp')
class TestMigrationRightOrder(test.BaseTestCase):
class TestMigrationRightOrder(test_base.BaseTestCase):
def setUp(self):
self.migration_config = {'alembic_ini_path': '.',

View File

@ -15,12 +15,12 @@
# under the License.
import mock
from oslotest import base as test_base
from openstack.common.db.sqlalchemy import test_migrations as migrate
from openstack.common import test
class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
class TestWalkVersions(test_base.BaseTestCase, migrate.WalkVersionsMixin):
def setUp(self):
super(TestWalkVersions, self).setUp()
self.migration_api = mock.MagicMock()

View File

@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslotest import base as oslo_test
from sqlalchemy import Column
from sqlalchemy import Integer, String
from sqlalchemy.ext.declarative import declarative_base
from openstack.common.db.sqlalchemy import models
from openstack.common.db.sqlalchemy import test_base
from openstack.common import test
BASE = declarative_base()
@ -111,7 +111,7 @@ class ExtraKeysModel(BASE, models.ModelBase):
return ['name']
class TimestampMixinTest(test.BaseTestCase):
class TimestampMixinTest(oslo_test.BaseTestCase):
def test_timestampmixin_attr(self):

View File

@ -21,6 +21,7 @@ import logging
import _mysql_exceptions
import mock
from oslotest import base as oslo_test
import sqlalchemy
from sqlalchemy import Column, MetaData, Table, UniqueConstraint
from sqlalchemy import DateTime, Integer, String
@ -33,7 +34,6 @@ from openstack.common.db.sqlalchemy import models
from openstack.common.db.sqlalchemy import session
from openstack.common.db.sqlalchemy import test_base
from openstack.common import log
from openstack.common import test
from tests.unit import test_log
@ -213,7 +213,7 @@ class FakeDB2Engine(object):
pass
class TestDBDisconnected(test.BaseTestCase):
class TestDBDisconnected(oslo_test.BaseTestCase):
def _test_ping_listener_disconnected(self, connection):
engine_args = {
@ -326,7 +326,7 @@ class MySQLTraditionalModeTestCase(MySQLStrictAllTablesModeTestCase):
self.mysql_mode = 'TRADITIONAL'
class EngineFacadeTestCase(test.BaseTestCase):
class EngineFacadeTestCase(oslo_test.BaseTestCase):
def setUp(self):
super(EngineFacadeTestCase, self).setUp()

View File

@ -18,6 +18,7 @@ import warnings
from migrate.changeset import UniqueConstraint
import mock
from oslotest import base as test_base
import six
from six import moves
from six.moves.urllib import parse
@ -38,14 +39,13 @@ from openstack.common.db.sqlalchemy import session
from openstack.common.db.sqlalchemy import test_migrations
from openstack.common.db.sqlalchemy import utils
from openstack.common.fixture import moxstubout
from openstack.common import test
from tests import utils as test_utils
SA_VERSION = tuple(map(int, sqlalchemy.__version__.split('.')))
class TestSanitizeDbUrl(test.BaseTestCase):
class TestSanitizeDbUrl(test_base.BaseTestCase):
def test_url_with_cred(self):
db_url = 'myproto://johndoe:secret@localhost/myschema'
@ -86,7 +86,7 @@ class FakeModel(object):
return '<FakeModel: %s>' % self.values
class TestPaginateQuery(test.BaseTestCase):
class TestPaginateQuery(test_base.BaseTestCase):
def setUp(self):
super(TestPaginateQuery, self).setUp()
mox_fixture = self.useFixture(moxstubout.MoxStubout())
@ -663,7 +663,7 @@ class TestConnectionUtils(test_utils.BaseTestCase):
('dude', 'pass', 'test', 'localhost'))
class TestRaiseDuplicateEntryError(test.BaseTestCase):
class TestRaiseDuplicateEntryError(test_base.BaseTestCase):
def _test_impl(self, engine_name, error_msg):
try:
error = sqlalchemy.exc.IntegrityError('test', 'test', error_msg)
@ -725,7 +725,7 @@ class MyModelSoftDeleted(declarative_base(), models.ModelBase,
id = Column(Integer, primary_key=True)
class TestModelQuery(test.BaseTestCase):
class TestModelQuery(test_base.BaseTestCase):
def setUp(self):
super(TestModelQuery, self).setUp()