diff --git a/.testr.conf b/.testr.conf index fb62267..8abf838 100644 --- a/.testr.conf +++ b/.testr.conf @@ -1,7 +1,4 @@ [DEFAULT] -test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ - OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ - OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ - ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} OS_TEST_TIMEOUT=60 ${PYTHON:-python} -m subunit.run discover -t ./ ${TESTS_DIR:-./cerberus/tests/unit/} $LISTOPT $IDOPTION test_id_option=--load-list $IDFILE test_list_option=--list \ No newline at end of file diff --git a/cerberus/tests/__init__.py b/cerberus/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cerberus/tests/api/__init__.py b/cerberus/tests/api/__init__.py deleted file mode 100644 index 73ca62b..0000000 --- a/cerberus/tests/api/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -# Copyright (c) 2014 EUROGICIEL -# -# 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. -# diff --git a/cerberus/tests/db/__init__.py b/cerberus/tests/db/__init__.py deleted file mode 100644 index b06b406..0000000 --- a/cerberus/tests/db/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -# Copyright (c) 2015 EUROGICIEL -# -# 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. -# diff --git a/cerberus/tests/unit/__init__.py b/cerberus/tests/unit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cerberus/tests/unit/api/__init__.py b/cerberus/tests/unit/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cerberus/tests/api/base.py b/cerberus/tests/unit/api/base.py similarity index 99% rename from cerberus/tests/api/base.py rename to cerberus/tests/unit/api/base.py index 85b4b5a..a7d8336 100644 --- a/cerberus/tests/api/base.py +++ b/cerberus/tests/unit/api/base.py @@ -19,7 +19,7 @@ import pecan.testing from cerberus.api import auth from cerberus.db import api as dbapi -from cerberus.tests import base +from cerberus.tests.unit import base PATH_PREFIX = '/v1' diff --git a/cerberus/tests/api/utils.py b/cerberus/tests/unit/api/utils.py similarity index 100% rename from cerberus/tests/api/utils.py rename to cerberus/tests/unit/api/utils.py diff --git a/cerberus/tests/api/v1/__init__.py b/cerberus/tests/unit/api/v1/__init__.py similarity index 100% rename from cerberus/tests/api/v1/__init__.py rename to cerberus/tests/unit/api/v1/__init__.py diff --git a/cerberus/tests/api/v1/test_plugins.py b/cerberus/tests/unit/api/v1/test_plugins.py similarity index 97% rename from cerberus/tests/api/v1/test_plugins.py rename to cerberus/tests/unit/api/v1/test_plugins.py index db157ae..2a99b5c 100644 --- a/cerberus/tests/api/v1/test_plugins.py +++ b/cerberus/tests/unit/api/v1/test_plugins.py @@ -15,14 +15,14 @@ # import json -import mock from sqlalchemy import exc +import mock from oslo import messaging from cerberus import db -from cerberus.tests.api import base -from cerberus.tests.db import utils as db_utils +from cerberus.tests.unit.api import base +from cerberus.tests.unit.db import utils as db_utils PLUGIN_ID_1 = 1 diff --git a/cerberus/tests/api/v1/test_security_alarms.py b/cerberus/tests/unit/api/v1/test_security_alarms.py similarity index 96% rename from cerberus/tests/api/v1/test_security_alarms.py rename to cerberus/tests/unit/api/v1/test_security_alarms.py index 42e371a..9cec853 100644 --- a/cerberus/tests/api/v1/test_security_alarms.py +++ b/cerberus/tests/unit/api/v1/test_security_alarms.py @@ -14,12 +14,14 @@ # limitations under the License. # -import mock from sqlalchemy import exc as sql_exc +import mock + from cerberus import db -from cerberus.tests.api import base -from cerberus.tests.db import utils as db_utils +from cerberus.tests.unit.api import base +from cerberus.tests.unit.db import utils as db_utils + SECURITY_ALARM_ID = 'abc123' SECURITY_ALARM_ID_2 = 'xyz789' diff --git a/cerberus/tests/api/v1/test_security_reports.py b/cerberus/tests/unit/api/v1/test_security_reports.py similarity index 97% rename from cerberus/tests/api/v1/test_security_reports.py rename to cerberus/tests/unit/api/v1/test_security_reports.py index 28260ef..f2c4278 100644 --- a/cerberus/tests/api/v1/test_security_reports.py +++ b/cerberus/tests/unit/api/v1/test_security_reports.py @@ -14,12 +14,14 @@ # limitations under the License. # -import mock from sqlalchemy import exc as sql_exc +import mock + from cerberus import db -from cerberus.tests.api import base -from cerberus.tests.db import utils as db_utils +from cerberus.tests.unit.api import base +from cerberus.tests.unit.db import utils as db_utils + SECURITY_REPORT_ID = 'abc123' SECURITY_REPORT_ID_2 = 'xyz789' diff --git a/cerberus/tests/api/v1/test_tasks.py b/cerberus/tests/unit/api/v1/test_tasks.py similarity index 98% rename from cerberus/tests/api/v1/test_tasks.py rename to cerberus/tests/unit/api/v1/test_tasks.py index 6f9fa43..0cd1bf3 100644 --- a/cerberus/tests/api/v1/test_tasks.py +++ b/cerberus/tests/unit/api/v1/test_tasks.py @@ -15,13 +15,13 @@ # import json -import mock +import mock from oslo import messaging from cerberus.api.v1.datamodels import task as task_model -from cerberus.tests.api import base -from cerberus.tests.db import utils as db_utils +from cerberus.tests.unit.api import base +from cerberus.tests.unit.db import utils as db_utils class MockTask(object): diff --git a/cerberus/tests/base.py b/cerberus/tests/unit/base.py similarity index 93% rename from cerberus/tests/base.py rename to cerberus/tests/unit/base.py index 57bd8ef..1b12f70 100644 --- a/cerberus/tests/base.py +++ b/cerberus/tests/unit/base.py @@ -18,9 +18,9 @@ import os from oslo.config import cfg from oslotest import base -from cerberus.tests import config_fixture -from cerberus.tests import policy_fixture -from cerberus.tests import utils +from cerberus.tests.unit import config_fixture +from cerberus.tests.unit import policy_fixture +from cerberus.tests.unit import utils CONF = cfg.CONF diff --git a/cerberus/tests/client/__init__.py b/cerberus/tests/unit/client/__init__.py similarity index 100% rename from cerberus/tests/client/__init__.py rename to cerberus/tests/unit/client/__init__.py diff --git a/cerberus/tests/client/test_keystone_client.py b/cerberus/tests/unit/client/test_keystone_client.py similarity index 98% rename from cerberus/tests/client/test_keystone_client.py rename to cerberus/tests/unit/client/test_keystone_client.py index 0e077c1..2029bf8 100644 --- a/cerberus/tests/client/test_keystone_client.py +++ b/cerberus/tests/unit/client/test_keystone_client.py @@ -15,11 +15,10 @@ # import mock - from oslo.config import cfg from cerberus.client import keystone_client -from cerberus.tests import base +from cerberus.tests.unit import base cfg.CONF.import_group('service_credentials', 'cerberus.service') diff --git a/cerberus/tests/client/test_neutron_client.py b/cerberus/tests/unit/client/test_neutron_client.py similarity index 99% rename from cerberus/tests/client/test_neutron_client.py rename to cerberus/tests/unit/client/test_neutron_client.py index 865c952..6ce6e0e 100644 --- a/cerberus/tests/client/test_neutron_client.py +++ b/cerberus/tests/unit/client/test_neutron_client.py @@ -15,11 +15,10 @@ # import mock - from oslo.config import cfg from cerberus.client import neutron_client -from cerberus.tests import base +from cerberus.tests.unit import base cfg.CONF.import_group('service_credentials', 'cerberus.service') diff --git a/cerberus/tests/client/test_nova_client.py b/cerberus/tests/unit/client/test_nova_client.py similarity index 99% rename from cerberus/tests/client/test_nova_client.py rename to cerberus/tests/unit/client/test_nova_client.py index e2d6f51..95a3aa8 100644 --- a/cerberus/tests/client/test_nova_client.py +++ b/cerberus/tests/unit/client/test_nova_client.py @@ -15,11 +15,10 @@ # import mock - from oslo.config import cfg from cerberus.client import nova_client -from cerberus.tests import base +from cerberus.tests.unit import base cfg.CONF.import_group('service_credentials', 'cerberus.service') diff --git a/cerberus/tests/config_fixture.py b/cerberus/tests/unit/config_fixture.py similarity index 100% rename from cerberus/tests/config_fixture.py rename to cerberus/tests/unit/config_fixture.py diff --git a/cerberus/tests/unit/db/__init__.py b/cerberus/tests/unit/db/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cerberus/tests/db/utils.py b/cerberus/tests/unit/db/utils.py similarity index 100% rename from cerberus/tests/db/utils.py rename to cerberus/tests/unit/db/utils.py diff --git a/cerberus/tests/fake_policy.py b/cerberus/tests/unit/fake_policy.py similarity index 100% rename from cerberus/tests/fake_policy.py rename to cerberus/tests/unit/fake_policy.py diff --git a/cerberus/tests/policy_fixture.py b/cerberus/tests/unit/policy_fixture.py similarity index 97% rename from cerberus/tests/policy_fixture.py rename to cerberus/tests/unit/policy_fixture.py index 815f39b..459810c 100644 --- a/cerberus/tests/policy_fixture.py +++ b/cerberus/tests/unit/policy_fixture.py @@ -14,14 +14,15 @@ # limitations under the License. # -import fixtures import os +import fixtures from oslo.config import cfg from cerberus.common import policy as cerberus_policy from cerberus.openstack.common import policy as common_policy -from cerberus.tests import fake_policy +from cerberus.tests.unit import fake_policy + CONF = cfg.CONF diff --git a/cerberus/tests/test_cerberus_manager.py b/cerberus/tests/unit/test_cerberus_manager.py similarity index 99% rename from cerberus/tests/test_cerberus_manager.py rename to cerberus/tests/unit/test_cerberus_manager.py index bd81890..7e97f6c 100644 --- a/cerberus/tests/test_cerberus_manager.py +++ b/cerberus/tests/unit/test_cerberus_manager.py @@ -25,10 +25,10 @@ from eventlet import greenpool import json import mock import pkg_resources +from stevedore import extension import uuid from oslo import messaging -from stevedore import extension from cerberus.common import errors from cerberus.common import loopingcall @@ -36,8 +36,8 @@ from cerberus.common import threadgroup from cerberus.db.sqlalchemy import api as db_api from cerberus import manager from cerberus.plugins import base as base_plugin -from cerberus.tests import base -from cerberus.tests.db import utils as db_utils +from cerberus.tests.unit import base +from cerberus.tests.unit.db import utils as db_utils PLUGIN_UUID = 'UUID' @@ -228,7 +228,7 @@ class TestCerberusManager(base.TestBase): def test_get_plugins(self): ctx = {"some": "context"} json_plugin1 = { - "name": "cerberus.tests.test_cerberus_manager.FakePlugin", + "name": "cerberus.tests.unit.test_cerberus_manager.FakePlugin", "subscribed_events": [ ], @@ -249,7 +249,7 @@ class TestCerberusManager(base.TestBase): c_manager.cerberus_manager = self.extension_mgr json_plugin1 = { - "name": "cerberus.tests.test_cerberus_manager.FakePlugin", + "name": "cerberus.tests.unit.test_cerberus_manager.FakePlugin", "subscribed_events": [ ], diff --git a/cerberus/tests/test_db_api.py b/cerberus/tests/unit/test_db_api.py similarity index 98% rename from cerberus/tests/test_db_api.py rename to cerberus/tests/unit/test_db_api.py index 67ac264..cb39d06 100644 --- a/cerberus/tests/test_db_api.py +++ b/cerberus/tests/unit/test_db_api.py @@ -19,12 +19,11 @@ Tests for `db api` module. """ import mock - from oslo.config import fixture as fixture_config from cerberus.db.sqlalchemy import api from cerberus.openstack.common.db.sqlalchemy import models as db_models -from cerberus.tests import base +from cerberus.tests.unit import base class DbApiTestCase(base.TestBase): diff --git a/cerberus/tests/test_notifications.py b/cerberus/tests/unit/test_notifications.py similarity index 98% rename from cerberus/tests/test_notifications.py rename to cerberus/tests/unit/test_notifications.py index cce05d1..36d42e6 100644 --- a/cerberus/tests/test_notifications.py +++ b/cerberus/tests/unit/test_notifications.py @@ -14,14 +14,14 @@ # limitations under the License. # -import mock import uuid +import mock from oslo.config import cfg from cerberus import notifications from cerberus.openstack.common.fixture import moxstubout -from cerberus.tests import base +from cerberus.tests.unit import base EXP_RESOURCE_TYPE = uuid.uuid4().hex diff --git a/cerberus/tests/test_utils.py b/cerberus/tests/unit/test_utils.py similarity index 100% rename from cerberus/tests/test_utils.py rename to cerberus/tests/unit/test_utils.py diff --git a/cerberus/tests/utils.py b/cerberus/tests/unit/utils.py similarity index 100% rename from cerberus/tests/utils.py rename to cerberus/tests/unit/utils.py diff --git a/test-requirements.txt b/test-requirements.txt index c8fd50a..72161df 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -14,6 +14,8 @@ python-subunit nose nose-exclude nosexcover +mox>=0.5.3,<=0.5.3 +tempest-lib>=0.5.0 # Doc requirements sphinx>=1.1.2,!=1.2.0,<1.3 diff --git a/tox.ini b/tox.ini index 38d3390..c8fbac4 100644 --- a/tox.ini +++ b/tox.ini @@ -6,20 +6,24 @@ skipsdist = True [testenv] usedevelop = True install_command = pip install -U {opts} {packages} -setenv = - VIRTUAL_ENV={envdir} +setenv = VIRTUAL_ENV={envdir} deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt +commands = + bash -c "TESTS_DIR=./cerberus/tests/unit/ python setup.py testr --slowest --testr-args='{posargs}'" + +[tox:jenkins] +downloadcache = ~/cache/pip [testenv:pep8] -commands = flake8 +commands = flake8 {posargs} cerberus [testenv:venv] commands = {posargs} [testenv:cover] commands = - nosetests --with-xunit --with-xcoverage --cover-package=cerberus --nocapture --cover-tests --cover-branches --cover-min-percentage=50 + python setup.py testr --coverage {posargs} [testenv:docs] commands = python setup.py build_sphinx @@ -47,4 +51,3 @@ ignore = E125,E126,E128,E129,E265,E713,F402,F811,F812,H104,H237,H305,H307,H401,H show-source = true builtins = _ exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools -