Changes tox to only run unit tests and moves unit tests to tests/unit.

Currently, the api and scenario tests are skipped when tox is run,
i.e. when tox -e py27 and tox -e py35 are executed. This is not ideal,
because an error could be thrown when trying to import modules into
the api and scenario tests. Instead, these tests should never
be discovered by ostestr. This will resolve issues with the new
framework changes [0].

This change simply creates a new file called test-whitelist.txt
which is used by the parameter --whitelist-file in the
command under [testenv] in tox.ini. It ensures that only
the regexes specified in test-whitelist.txt are executed [1] --
so only the unit tests are executed with tox (as currently
no functional tests are in Patrole).

Also added check-uuid to pep8 in tox.ini.

[0] https://review.openstack.org/#/c/433741/
[1] https://docs.openstack.org/developer/os-testr/ostestr.html

Change-Id: I1c6bca9044a74e8909754f106880636739e5a822
This commit is contained in:
Felipe Monteiro 2017-02-27 03:53:50 +00:00
parent 2a91709282
commit df958705cd
14 changed files with 22 additions and 17 deletions

View File

@ -15,7 +15,7 @@
from tempest.common.utils import data_utils
from tempest.lib.common.utils import test_utils
from tempest import test
from tempest.lib import decorators
from patrole_tempest_plugin import rbac_rule_validation
from patrole_tempest_plugin.rbac_utils import rbac_utils
@ -52,7 +52,7 @@ class IdentityCredentialsV3AdminRbacTest(
@rbac_rule_validation.action(service="keystone",
rule="identity:create_credential")
@test.idempotent_id('c1ab6d34-c59f-4ae1-bae9-bb3c1089b48e')
@decorators.idempotent_id('c1ab6d34-c59f-4ae1-bae9-bb3c1089b48e')
def test_create_credential(self):
"""Create a Credential.
@ -63,7 +63,7 @@ class IdentityCredentialsV3AdminRbacTest(
@rbac_rule_validation.action(service="keystone",
rule="identity:update_credential")
@test.idempotent_id('cfb05ce3-bffb-496e-a3c2-9515d730da63')
@decorators.idempotent_id('cfb05ce3-bffb-496e-a3c2-9515d730da63')
def test_update_credential(self):
"""Update a Credential.
@ -84,7 +84,7 @@ class IdentityCredentialsV3AdminRbacTest(
@rbac_rule_validation.action(service="keystone",
rule="identity:delete_credential")
@test.idempotent_id('87ab42af-8d41-401b-90df-21e72919fcde')
@decorators.idempotent_id('87ab42af-8d41-401b-90df-21e72919fcde')
def test_delete_credential(self):
"""Delete a Credential.
@ -97,7 +97,7 @@ class IdentityCredentialsV3AdminRbacTest(
@rbac_rule_validation.action(service="keystone",
rule="identity:get_credential")
@test.idempotent_id('1b6eeae6-f1e8-4cdf-8903-1c002b1fc271')
@decorators.idempotent_id('1b6eeae6-f1e8-4cdf-8903-1c002b1fc271')
def test_show_credential(self):
"""Show/Get a Credential.
@ -110,7 +110,7 @@ class IdentityCredentialsV3AdminRbacTest(
@rbac_rule_validation.action(service="keystone",
rule="identity:list_credentials")
@test.idempotent_id('3de303e2-12a7-4811-805a-f18906472038')
@decorators.idempotent_id('3de303e2-12a7-4811-805a-f18906472038')
def test_list_credentials(self):
"""List all Credentials.

View File

@ -15,7 +15,7 @@
from tempest.common.utils import data_utils
from tempest import config
from tempest import test
from tempest.lib import decorators
from patrole_tempest_plugin import rbac_rule_validation
from patrole_tempest_plugin.rbac_utils import rbac_utils
@ -33,7 +33,7 @@ class IdentitySericesV3AdminRbacTest(rbac_base.BaseIdentityV3RbacAdminTest):
@rbac_rule_validation.action(service="keystone",
rule="identity:create_service")
@test.idempotent_id('9a4bb317-f0bb-4005-8df0-4b672885b7c8')
@decorators.idempotent_id('9a4bb317-f0bb-4005-8df0-4b672885b7c8')
def test_create_service(self):
"""Create a service.
@ -44,7 +44,7 @@ class IdentitySericesV3AdminRbacTest(rbac_base.BaseIdentityV3RbacAdminTest):
@rbac_rule_validation.action(service="keystone",
rule="identity:update_service")
@test.idempotent_id('b39447d1-2cf6-40e5-a899-46f287f2ecf0')
@decorators.idempotent_id('b39447d1-2cf6-40e5-a899-46f287f2ecf0')
def test_update_service(self):
"""Update a service.
@ -61,7 +61,7 @@ class IdentitySericesV3AdminRbacTest(rbac_base.BaseIdentityV3RbacAdminTest):
@rbac_rule_validation.action(service="keystone",
rule="identity:delete_service")
@test.idempotent_id('177b991a-438d-4bef-8e9f-9c6cc5a1c9e8')
@decorators.idempotent_id('177b991a-438d-4bef-8e9f-9c6cc5a1c9e8')
def test_delete_service(self):
"""Delete a service.
@ -74,7 +74,7 @@ class IdentitySericesV3AdminRbacTest(rbac_base.BaseIdentityV3RbacAdminTest):
@rbac_rule_validation.action(service="keystone",
rule="identity:get_service")
@test.idempotent_id('d89a9ac6-cd53-428d-84c0-5bc71f4a432d')
@decorators.idempotent_id('d89a9ac6-cd53-428d-84c0-5bc71f4a432d')
def test_show_service(self):
"""Show/Get a service.
@ -87,7 +87,7 @@ class IdentitySericesV3AdminRbacTest(rbac_base.BaseIdentityV3RbacAdminTest):
@rbac_rule_validation.action(service="keystone",
rule="identity:list_services")
@test.idempotent_id('706e6bea-3385-4718-919c-0b5121395806')
@decorators.idempotent_id('706e6bea-3385-4718-919c-0b5121395806')
def test_list_services(self):
"""list all services.

View File

@ -20,7 +20,7 @@ test_patrole
Tests for `patrole` module.
"""
from tests import base
from patrole_tempest_plugin.tests.unit import base
class TestPatrole(base.TestCase):

1
test-whitelist.txt Normal file
View File

@ -0,0 +1 @@
patrole_tempest_plugin.tests.unit.test*

12
tox.ini
View File

@ -1,6 +1,6 @@
[tox]
minversion = 1.6
envlist = py35,py27,pypy,pep8
envlist = pep8,py35,py27
skipsdist = True
[testenv]
@ -9,16 +9,20 @@ install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstac
setenv =
VIRTUAL_ENV={envdir}
PYTHONWARNINGS=default::DeprecationWarning
passenv = OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_TEST_TIMEOUT OS_TEST_LOCK_PATH OS_TEST_PATH TEMPEST_CONFIG TEMPEST_CONFIG_DIR http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
whitelist_externals = *
passenv = OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_TEST_TIMEOUT OS_TEST_LOCK_PATH OS_TEST_PATH http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
whitelist_externals = find
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =
find . -type f -name "*.pyc" -delete
ostestr {posargs}
ostestr {posargs} --whitelist-file test-whitelist.txt
[testenv:pep8]
commands = flake8 {posargs}
check-uuid
[testenv:uuidgen]
commands = check-uuid --fix
[testenv:venv]
commands = {posargs}