diff options
author | Victor Sergeyev <vsergeyev@mirantis.com> | 2014-04-18 11:33:16 +0300 |
---|---|---|
committer | Victor Sergeyev <vsergeyev@mirantis.com> | 2014-04-18 11:33:16 +0300 |
commit | e4cfa6d39d2aa53af64ab34de97183f98fbeb667 (patch) | |
tree | 219fee2ad0aa87c7471977470d563f48d1b97cd9 /tests | |
parent | b5e4815563334958d081e0fef30f25113d80555f (diff) | |
download | oslo-db-e4cfa6d39d2aa53af64ab34de97183f98fbeb667.tar.gz |
Fix the graduate.sh script result
Diffstat (limited to 'tests')
-rw-r--r-- | tests/__init__.py | 13 | ||||
-rw-r--r-- | tests/base.py | 54 | ||||
-rw-r--r-- | tests/test_db.py | 28 | ||||
-rw-r--r-- | tests/unit/db/sqlalchemy/test_migrate.py | 4 | ||||
-rw-r--r-- | tests/unit/db/sqlalchemy/test_migrate_cli.py | 10 | ||||
-rw-r--r-- | tests/unit/db/sqlalchemy/test_migration_common.py | 6 | ||||
-rw-r--r-- | tests/unit/db/sqlalchemy/test_migrations.py | 2 | ||||
-rw-r--r-- | tests/unit/db/sqlalchemy/test_models.py | 4 | ||||
-rw-r--r-- | tests/unit/db/sqlalchemy/test_options.py | 2 | ||||
-rw-r--r-- | tests/unit/db/sqlalchemy/test_sqlalchemy.py | 12 | ||||
-rw-r--r-- | tests/unit/db/sqlalchemy/test_utils.py | 12 | ||||
-rw-r--r-- | tests/unit/db/test_api.py | 4 |
12 files changed, 123 insertions, 28 deletions
diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..f88664e --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +# 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.
\ No newline at end of file diff --git a/tests/base.py b/tests/base.py new file mode 100644 index 0000000..f9a09a8 --- /dev/null +++ b/tests/base.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- + +# Copyright 2010-2011 OpenStack Foundation +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# 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 os + +import fixtures +import testtools + +_TRUE_VALUES = ('true', '1', 'yes') + +# FIXME(dhellmann) Update this to use oslo.test library + +class TestCase(testtools.TestCase): + + """Test case base class for all unit tests.""" + + def setUp(self): + """Run before each test method to initialize test environment.""" + + super(TestCase, self).setUp() + test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0) + try: + test_timeout = int(test_timeout) + except ValueError: + # If timeout value is invalid do not set a timeout. + test_timeout = 0 + if test_timeout > 0: + self.useFixture(fixtures.Timeout(test_timeout, gentle=True)) + + self.useFixture(fixtures.NestedTempfile()) + self.useFixture(fixtures.TempHomeDir()) + + if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES: + stdout = self.useFixture(fixtures.StringStream('stdout')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout)) + if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES: + stderr = self.useFixture(fixtures.StringStream('stderr')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) + + self.log_fixture = self.useFixture(fixtures.FakeLogger())
\ No newline at end of file diff --git a/tests/test_db.py b/tests/test_db.py new file mode 100644 index 0000000..6156b0e --- /dev/null +++ b/tests/test_db.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# 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. + +""" +test_db +---------------------------------- + +Tests for `db` module. +""" + +from . import base + + +class TestDb(base.TestCase): + + def test_something(self): + pass
\ No newline at end of file diff --git a/tests/unit/db/sqlalchemy/test_migrate.py b/tests/unit/db/sqlalchemy/test_migrate.py index a6e9700..23833e1 100644 --- a/tests/unit/db/sqlalchemy/test_migrate.py +++ b/tests/unit/db/sqlalchemy/test_migrate.py @@ -17,8 +17,8 @@ from migrate.changeset.constraint import UniqueConstraint from migrate.changeset.databases import sqlite import sqlalchemy as sa -from openstack.common.db.sqlalchemy import migration -from openstack.common.db.sqlalchemy import test_base +from oslo.db.sqlalchemy import migration +from oslo.db.sqlalchemy import test_base def uniques(*constraints): diff --git a/tests/unit/db/sqlalchemy/test_migrate_cli.py b/tests/unit/db/sqlalchemy/test_migrate_cli.py index 9e33bf5..f23ee87 100644 --- a/tests/unit/db/sqlalchemy/test_migrate_cli.py +++ b/tests/unit/db/sqlalchemy/test_migrate_cli.py @@ -13,9 +13,9 @@ 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 oslo.db.sqlalchemy.migration_cli import ext_alembic +from oslo.db.sqlalchemy.migration_cli import ext_migrate +from oslo.db.sqlalchemy.migration_cli import manager class MockWithCmp(mock.MagicMock): @@ -26,7 +26,7 @@ class MockWithCmp(mock.MagicMock): return self.order > other.order -@mock.patch(('openstack.common.db.sqlalchemy.migration_cli.' +@mock.patch(('oslo.db.sqlalchemy.migration_cli.' 'ext_alembic.alembic.command')) class TestAlembicExtension(test_base.BaseTestCase): @@ -86,7 +86,7 @@ class TestAlembicExtension(test_base.BaseTestCase): self.assertIsNone(version) -@mock.patch(('openstack.common.db.sqlalchemy.migration_cli.' +@mock.patch(('oslo.db.sqlalchemy.migration_cli.' 'ext_migrate.migration')) class TestMigrateExtension(test_base.BaseTestCase): diff --git a/tests/unit/db/sqlalchemy/test_migration_common.py b/tests/unit/db/sqlalchemy/test_migration_common.py index 789c168..9f05aff 100644 --- a/tests/unit/db/sqlalchemy/test_migration_common.py +++ b/tests/unit/db/sqlalchemy/test_migration_common.py @@ -23,9 +23,9 @@ from migrate.versioning import api as versioning_api import mock import sqlalchemy -from openstack.common.db import exception as db_exception -from openstack.common.db.sqlalchemy import migration -from openstack.common.db.sqlalchemy import test_base +from oslo.db import exception as db_exception +from oslo.db.sqlalchemy import migration +from oslo.db.sqlalchemy import test_base class TestMigrationCommon(test_base.DbTestCase): diff --git a/tests/unit/db/sqlalchemy/test_migrations.py b/tests/unit/db/sqlalchemy/test_migrations.py index 1b65ffa..f39bb73 100644 --- a/tests/unit/db/sqlalchemy/test_migrations.py +++ b/tests/unit/db/sqlalchemy/test_migrations.py @@ -17,7 +17,7 @@ import mock from oslotest import base as test_base -from openstack.common.db.sqlalchemy import test_migrations as migrate +from oslo.db.sqlalchemy import test_migrations as migrate class TestWalkVersions(test_base.BaseTestCase, migrate.WalkVersionsMixin): diff --git a/tests/unit/db/sqlalchemy/test_models.py b/tests/unit/db/sqlalchemy/test_models.py index 13783d5..8c23da8 100644 --- a/tests/unit/db/sqlalchemy/test_models.py +++ b/tests/unit/db/sqlalchemy/test_models.py @@ -18,8 +18,8 @@ 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 oslo.db.sqlalchemy import models +from oslo.db.sqlalchemy import test_base BASE = declarative_base() diff --git a/tests/unit/db/sqlalchemy/test_options.py b/tests/unit/db/sqlalchemy/test_options.py index c5faa2c..10d6451 100644 --- a/tests/unit/db/sqlalchemy/test_options.py +++ b/tests/unit/db/sqlalchemy/test_options.py @@ -17,7 +17,7 @@ from openstack.common.fixture import config from tests import utils as test_utils -cfg.CONF.import_opt('connection', 'openstack.common.db.options', +cfg.CONF.import_opt('connection', 'oslo.db.options', group='database') diff --git a/tests/unit/db/sqlalchemy/test_sqlalchemy.py b/tests/unit/db/sqlalchemy/test_sqlalchemy.py index 9212bef..9cda622 100644 --- a/tests/unit/db/sqlalchemy/test_sqlalchemy.py +++ b/tests/unit/db/sqlalchemy/test_sqlalchemy.py @@ -29,10 +29,10 @@ from sqlalchemy import exc as sqla_exc from sqlalchemy.exc import DataError from sqlalchemy.ext.declarative import declarative_base -from openstack.common.db import exception as db_exc -from openstack.common.db.sqlalchemy import models -from openstack.common.db.sqlalchemy import session -from openstack.common.db.sqlalchemy import test_base +from oslo.db import exception as db_exc +from oslo.db.sqlalchemy import models +from oslo.db.sqlalchemy import session +from oslo.db.sqlalchemy import test_base BASE = declarative_base() @@ -348,8 +348,8 @@ class EngineFacadeTestCase(oslo_test.BaseTestCase): self.assertFalse(ses.autocommit) self.assertTrue(ses.expire_on_commit) - @mock.patch('openstack.common.db.sqlalchemy.session.get_maker') - @mock.patch('openstack.common.db.sqlalchemy.session.create_engine') + @mock.patch('oslo.db.sqlalchemy.session.get_maker') + @mock.patch('oslo.db.sqlalchemy.session.create_engine') def test_creation_from_config(self, create_engine, get_maker): conf = mock.MagicMock() conf.database.items.return_value = [ diff --git a/tests/unit/db/sqlalchemy/test_utils.py b/tests/unit/db/sqlalchemy/test_utils.py index a2335b6..d7f1783 100644 --- a/tests/unit/db/sqlalchemy/test_utils.py +++ b/tests/unit/db/sqlalchemy/test_utils.py @@ -32,12 +32,12 @@ from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.sql import select from sqlalchemy.types import UserDefinedType, NullType -from openstack.common.db import exception -from openstack.common.db.sqlalchemy import migration -from openstack.common.db.sqlalchemy import models -from openstack.common.db.sqlalchemy import session -from openstack.common.db.sqlalchemy import test_migrations -from openstack.common.db.sqlalchemy import utils +from oslo.db import exception +from oslo.db.sqlalchemy import migration +from oslo.db.sqlalchemy import models +from oslo.db.sqlalchemy import session +from oslo.db.sqlalchemy import test_migrations +from oslo.db.sqlalchemy import utils from openstack.common.fixture import moxstubout from tests import utils as test_utils diff --git a/tests/unit/db/test_api.py b/tests/unit/db/test_api.py index 1f10d9d..c4b2bb9 100644 --- a/tests/unit/db/test_api.py +++ b/tests/unit/db/test_api.py @@ -17,8 +17,8 @@ import mock -from openstack.common.db import api -from openstack.common.db import exception +from oslo.db import api +from oslo.db import exception from openstack.common import importutils from tests import utils as test_utils |