Move tests in keystoneclient

This is the suggested location for tests and is adopted by most
projects. As part of this change relative imports to package imports.

Fix all the test running and coverage code to point to the new location.

Change-Id: I01264aed14f396ab9a7242e3e72b71e1bc332675
This commit is contained in:
Jamie Lennox
2013-09-23 12:07:40 +10:00
parent 7f0df0ab4c
commit 0a18d8bbdf
52 changed files with 59 additions and 65 deletions

View File

@@ -1,7 +1,7 @@
[run] [run]
branch = True branch = True
source = keystoneclient source = keystoneclient
omit = keystoneclient/openstack/* omit = keystoneclient/tests/*,keystoneclient/openstack/*
[report] [report]
ignore-errors = True ignore-errors = True

View File

@@ -1,4 +1,4 @@
[DEFAULT] [DEFAULT]
test_command=${PYTHON:-python} -m subunit.run discover -t ./ ./tests $LISTOPT $IDOPTION test_command=${PYTHON:-python} -m subunit.run discover -t ./ ./keystoneclient/tests $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE test_id_option=--load-list $IDFILE
test_list_option=--list test_list_option=--list

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.
from tests import utils
from keystoneclient.apiclient import exceptions from keystoneclient.apiclient import exceptions
from keystoneclient.tests import utils
class FakeResponse(object): class FakeResponse(object):

View File

@@ -22,9 +22,10 @@ from keystoneclient.openstack.common import timeutils
from keystoneclient import utils from keystoneclient import utils
ROOTDIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) CLIENTDIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
CERTDIR = os.path.join(ROOTDIR, "examples/pki/certs") ROOTDIR = os.path.dirname(CLIENTDIR)
CMSDIR = os.path.join(ROOTDIR, "examples/pki/cms") CERTDIR = os.path.join(ROOTDIR, 'examples', 'pki', 'certs')
CMSDIR = os.path.join(ROOTDIR, 'examples', 'pki', 'cms')
# @TODO(mordred) This should become a testresources resource attached to the # @TODO(mordred) This should become a testresources resource attached to the

View File

@@ -34,8 +34,8 @@ from keystoneclient.middleware import auth_token
from keystoneclient.openstack.common import jsonutils from keystoneclient.openstack.common import jsonutils
from keystoneclient.openstack.common import memorycache from keystoneclient.openstack.common import memorycache
from keystoneclient.openstack.common import timeutils from keystoneclient.openstack.common import timeutils
from keystoneclient.tests import client_fixtures
import client_fixtures
EXPECTED_V2_DEFAULT_ENV_RESPONSE = { EXPECTED_V2_DEFAULT_ENV_RESPONSE = {
'HTTP_X_IDENTITY_STATUS': 'Confirmed', 'HTTP_X_IDENTITY_STATUS': 'Confirmed',

View File

@@ -13,9 +13,9 @@
# under the License. # under the License.
from keystoneclient import base from keystoneclient import base
from keystoneclient.tests import utils
from keystoneclient.v2_0 import client from keystoneclient.v2_0 import client
from keystoneclient.v2_0 import roles from keystoneclient.v2_0 import roles
from tests import utils
class HumanReadable(base.Resource): class HumanReadable(base.Resource):

View File

@@ -20,7 +20,7 @@ from testtools import matchers
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient import httpclient from keystoneclient import httpclient
from tests import utils from keystoneclient.tests import utils
RESPONSE_BODY = '{"hi": "there"}' RESPONSE_BODY = '{"hi": "there"}'

View File

@@ -17,7 +17,7 @@ import mock
import requests import requests
from keystoneclient import httpclient from keystoneclient import httpclient
from tests import utils from keystoneclient.tests import utils
FAKE_RESPONSE = utils.TestResponse({ FAKE_RESPONSE = utils.TestResponse({
"status_code": 200, "status_code": 200,

View File

@@ -19,9 +19,8 @@ import mock
from keystoneclient import access from keystoneclient import access
from keystoneclient import httpclient from keystoneclient import httpclient
from keystoneclient.openstack.common import timeutils from keystoneclient.openstack.common import timeutils
from keystoneclient.tests import utils
from tests import utils from keystoneclient.tests.v2_0 import client_fixtures
from tests.v2_0 import client_fixtures
try: try:
import keyring # noqa import keyring # noqa

View File

@@ -26,8 +26,9 @@ from testtools import matchers
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient import shell as openstack_shell from keystoneclient import shell as openstack_shell
from keystoneclient.tests import utils
from keystoneclient.v2_0 import shell as shell_v2_0 from keystoneclient.v2_0 import shell as shell_v2_0
from tests import utils
DEFAULT_USERNAME = 'username' DEFAULT_USERNAME = 'username'
DEFAULT_PASSWORD = 'password' DEFAULT_PASSWORD = 'password'

View File

@@ -13,8 +13,8 @@
# under the License. # under the License.
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.tests import utils as test_utils
from keystoneclient import utils from keystoneclient import utils
from tests import utils as test_utils
class FakeResource(object): class FakeResource(object):

View File

@@ -15,8 +15,8 @@
import urlparse import urlparse
from tests import fakes from keystoneclient.tests import fakes
from tests.v2_0 import utils from keystoneclient.tests.v2_0 import utils
class FakeHTTPClient(fakes.FakeClient): class FakeHTTPClient(fakes.FakeClient):

View File

@@ -16,9 +16,9 @@ import datetime
from keystoneclient import access from keystoneclient import access
from keystoneclient.openstack.common import timeutils from keystoneclient.openstack.common import timeutils
from tests import client_fixtures as token_data from keystoneclient.tests import client_fixtures as token_data
from tests.v2_0 import client_fixtures from keystoneclient.tests.v2_0 import client_fixtures
from tests.v2_0 import utils from keystoneclient.tests.v2_0 import utils
UNSCOPED_TOKEN = client_fixtures.UNSCOPED_TOKEN UNSCOPED_TOKEN = client_fixtures.UNSCOPED_TOKEN
PROJECT_SCOPED_TOKEN = client_fixtures.PROJECT_SCOPED_TOKEN PROJECT_SCOPED_TOKEN = client_fixtures.PROJECT_SCOPED_TOKEN

View File

@@ -19,8 +19,8 @@ import httpretty
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.openstack.common import timeutils from keystoneclient.openstack.common import timeutils
from keystoneclient.tests.v2_0 import utils
from keystoneclient.v2_0 import client from keystoneclient.v2_0 import client
from tests.v2_0 import utils
class AuthenticateAgainstKeystoneTests(utils.TestCase): class AuthenticateAgainstKeystoneTests(utils.TestCase):

View File

@@ -17,9 +17,9 @@ import json
import httpretty import httpretty
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.tests.v2_0 import client_fixtures
from keystoneclient.tests.v2_0 import utils
from keystoneclient.v2_0 import client from keystoneclient.v2_0 import client
from tests.v2_0 import client_fixtures
from tests.v2_0 import utils
class KeystoneClientTest(utils.TestCase): class KeystoneClientTest(utils.TestCase):

View File

@@ -15,7 +15,7 @@
import httpretty import httpretty
from keystoneclient.generic import client from keystoneclient.generic import client
from tests.v2_0 import utils from keystoneclient.tests.v2_0 import utils
class DiscoverKeystoneTests(utils.UnauthenticatedTestCase): class DiscoverKeystoneTests(utils.UnauthenticatedTestCase):

View File

@@ -14,8 +14,8 @@
import httpretty import httpretty
from keystoneclient.tests.v2_0 import utils
from keystoneclient.v2_0 import ec2 from keystoneclient.v2_0 import ec2
from tests.v2_0 import utils
class EC2Tests(utils.TestCase): class EC2Tests(utils.TestCase):

View File

@@ -14,8 +14,8 @@
import httpretty import httpretty
from keystoneclient.tests.v2_0 import utils
from keystoneclient.v2_0 import endpoints from keystoneclient.v2_0 import endpoints
from tests.v2_0 import utils
class EndpointTests(utils.TestCase): class EndpointTests(utils.TestCase):

View File

@@ -14,8 +14,8 @@
import httpretty import httpretty
from keystoneclient.tests.v2_0 import utils
from keystoneclient.v2_0 import roles from keystoneclient.v2_0 import roles
from tests.v2_0 import utils
class RoleTests(utils.TestCase): class RoleTests(utils.TestCase):

View File

@@ -16,9 +16,8 @@ import copy
from keystoneclient import access from keystoneclient import access
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.tests.v2_0 import client_fixtures
from tests.v2_0 import client_fixtures from keystoneclient.tests.v2_0 import utils
from tests.v2_0 import utils
class ServiceCatalogTest(utils.TestCase): class ServiceCatalogTest(utils.TestCase):

View File

@@ -14,8 +14,8 @@
import httpretty import httpretty
from keystoneclient.tests.v2_0 import utils
from keystoneclient.v2_0 import services from keystoneclient.v2_0 import services
from tests.v2_0 import utils
class ServiceTests(utils.TestCase): class ServiceTests(utils.TestCase):

View File

@@ -20,9 +20,8 @@ from mox3 import stubout
from testtools import matchers from testtools import matchers
from keystoneclient import httpclient from keystoneclient import httpclient
from keystoneclient.tests.v2_0 import fakes
from tests.v2_0 import fakes from keystoneclient.tests.v2_0 import utils
from tests.v2_0 import utils
DEFAULT_USERNAME = 'username' DEFAULT_USERNAME = 'username'

View File

@@ -15,8 +15,8 @@
import httpretty import httpretty
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.tests.v2_0 import utils
from keystoneclient.v2_0 import tenants from keystoneclient.v2_0 import tenants
from tests.v2_0 import utils
class TenantTests(utils.TestCase): class TenantTests(utils.TestCase):

View File

@@ -14,7 +14,7 @@
import httpretty import httpretty
from tests.v2_0 import utils from keystoneclient.tests.v2_0 import utils
class TokenTests(utils.TestCase): class TokenTests(utils.TestCase):

View File

@@ -14,8 +14,8 @@
import httpretty import httpretty
from keystoneclient.tests.v2_0 import utils
from keystoneclient.v2_0 import users from keystoneclient.v2_0 import users
from tests.v2_0 import utils
class UserTests(utils.TestCase): class UserTests(utils.TestCase):

View File

@@ -14,8 +14,8 @@
import httpretty import httpretty
from keystoneclient.tests import utils
from keystoneclient.v2_0 import client from keystoneclient.v2_0 import client
from tests import utils
TestResponse = utils.TestResponse TestResponse = utils.TestResponse

View File

@@ -16,8 +16,8 @@ import datetime
from keystoneclient import access from keystoneclient import access
from keystoneclient.openstack.common import timeutils from keystoneclient.openstack.common import timeutils
from tests.v3 import client_fixtures from keystoneclient.tests.v3 import client_fixtures
from tests.v3 import utils from keystoneclient.tests.v3 import utils
TOKEN_RESPONSE = utils.TestResponse({ TOKEN_RESPONSE = utils.TestResponse({
"headers": client_fixtures.AUTH_RESPONSE_HEADERS "headers": client_fixtures.AUTH_RESPONSE_HEADERS

View File

@@ -15,10 +15,9 @@
import httpretty import httpretty
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.tests.v3 import utils
from keystoneclient.v3 import client from keystoneclient.v3 import client
from tests.v3 import utils
class AuthenticateAgainstKeystoneTests(utils.TestCase): class AuthenticateAgainstKeystoneTests(utils.TestCase):
def setUp(self): def setUp(self):

View File

@@ -17,11 +17,10 @@ import json
import httpretty import httpretty
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.tests.v3 import client_fixtures
from keystoneclient.tests.v3 import utils
from keystoneclient.v3 import client from keystoneclient.v3 import client
from tests.v3 import client_fixtures
from tests.v3 import utils
class KeystoneClientTest(utils.TestCase): class KeystoneClientTest(utils.TestCase):

View File

@@ -14,8 +14,8 @@
import uuid import uuid
from keystoneclient.tests.v3 import utils
from keystoneclient.v3 import credentials from keystoneclient.v3 import credentials
from tests.v3 import utils
class CredentialTests(utils.TestCase, utils.CrudTests): class CredentialTests(utils.TestCase, utils.CrudTests):

View File

@@ -17,7 +17,7 @@ import json
import httpretty import httpretty
from keystoneclient.generic import client from keystoneclient.generic import client
from tests.v3 import utils from keystoneclient.tests.v3 import utils
class DiscoverKeystoneTests(utils.UnauthenticatedTestCase): class DiscoverKeystoneTests(utils.UnauthenticatedTestCase):

View File

@@ -14,8 +14,8 @@
import uuid import uuid
from keystoneclient.tests.v3 import utils
from keystoneclient.v3 import domains from keystoneclient.v3 import domains
from tests.v3 import utils
class DomainTests(utils.TestCase, utils.CrudTests): class DomainTests(utils.TestCase, utils.CrudTests):

View File

@@ -14,8 +14,8 @@
import uuid import uuid
from keystoneclient.tests.v3 import utils
from keystoneclient.v3 import endpoints from keystoneclient.v3 import endpoints
from tests.v3 import utils
class EndpointTests(utils.TestCase, utils.CrudTests): class EndpointTests(utils.TestCase, utils.CrudTests):

View File

@@ -18,8 +18,8 @@ import uuid
import httpretty import httpretty
from keystoneclient.tests.v3 import utils
from keystoneclient.v3 import groups from keystoneclient.v3 import groups
from tests.v3 import utils
class GroupTests(utils.TestCase, utils.CrudTests): class GroupTests(utils.TestCase, utils.CrudTests):

View File

@@ -14,8 +14,8 @@
import uuid import uuid
from keystoneclient.tests.v3 import utils
from keystoneclient.v3 import policies from keystoneclient.v3 import policies
from tests.v3 import utils
class PolicyTests(utils.TestCase, utils.CrudTests): class PolicyTests(utils.TestCase, utils.CrudTests):

View File

@@ -16,8 +16,8 @@ import uuid
import httpretty import httpretty
from keystoneclient.tests.v3 import utils
from keystoneclient.v3 import projects from keystoneclient.v3 import projects
from tests.v3 import utils
class ProjectTests(utils.TestCase, utils.CrudTests): class ProjectTests(utils.TestCase, utils.CrudTests):

View File

@@ -19,8 +19,8 @@ import uuid
import httpretty import httpretty
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.tests.v3 import utils
from keystoneclient.v3 import roles from keystoneclient.v3 import roles
from tests.v3 import utils
class RoleTests(utils.TestCase, utils.CrudTests): class RoleTests(utils.TestCase, utils.CrudTests):

View File

@@ -16,9 +16,8 @@ import copy
from keystoneclient import access from keystoneclient import access
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.tests.v3 import client_fixtures
from tests.v3 import client_fixtures from keystoneclient.tests.v3 import utils
from tests.v3 import utils
class ServiceCatalogTest(utils.TestCase): class ServiceCatalogTest(utils.TestCase):

View File

@@ -14,8 +14,8 @@
import uuid import uuid
from keystoneclient.tests.v3 import utils
from keystoneclient.v3 import services from keystoneclient.v3 import services
from tests.v3 import utils
class ServiceTests(utils.TestCase, utils.CrudTests): class ServiceTests(utils.TestCase, utils.CrudTests):

View File

@@ -17,8 +17,8 @@ import uuid
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.openstack.common import timeutils from keystoneclient.openstack.common import timeutils
from keystoneclient.tests.v3 import utils
from keystoneclient.v3.contrib import trusts from keystoneclient.v3.contrib import trusts
from tests.v3 import utils
class TrustTests(utils.TestCase, utils.CrudTests): class TrustTests(utils.TestCase, utils.CrudTests):

View File

@@ -19,8 +19,8 @@ import uuid
import httpretty import httpretty
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.tests.v3 import utils
from keystoneclient.v3 import users from keystoneclient.v3 import users
from tests.v3 import utils
class UserTests(utils.TestCase, utils.CrudTests): class UserTests(utils.TestCase, utils.CrudTests):

View File

@@ -18,10 +18,9 @@ import uuid
import httpretty import httpretty
from keystoneclient.openstack.common import jsonutils from keystoneclient.openstack.common import jsonutils
from keystoneclient.tests import utils
from keystoneclient.v3 import client from keystoneclient.v3 import client
from tests import utils
TestResponse = utils.TestResponse TestResponse = utils.TestResponse

View File

@@ -81,7 +81,7 @@ function run_tests {
if [ "$testropts" = "" ] && [ "$testrargs" = "" ]; then if [ "$testropts" = "" ] && [ "$testrargs" = "" ]; then
# Default to running all tests if specific test is not # Default to running all tests if specific test is not
# provided. # provided.
testrargs="discover ./tests" testrargs="discover ./keystoneclient/tests"
fi fi
${wrapper} python -m testtools.run $testropts $testrargs ${wrapper} python -m testtools.run $testropts $testrargs
@@ -112,7 +112,7 @@ function run_tests {
echo "Generating coverage report in covhtml/" echo "Generating coverage report in covhtml/"
# Don't compute coverage for common code, which is tested elsewhere # Don't compute coverage for common code, which is tested elsewhere
${wrapper} coverage combine ${wrapper} coverage combine
${wrapper} coverage html --include='keystoneclient/*' --omit='keystoneclient/openstack/common/*' -d covhtml -i ${wrapper} coverage html -d covhtml -i
fi fi
return $RESULT return $RESULT
@@ -127,7 +127,7 @@ function copy_subunit_log {
function run_flake8 { function run_flake8 {
echo "Running flake8 ..." echo "Running flake8 ..."
srcfiles="keystoneclient tests" srcfiles="keystoneclient"
# Just run Flake8 in current environment # Just run Flake8 in current environment
${wrapper} flake8 ${srcfiles} ${wrapper} flake8 ${srcfiles}
} }