diff options
| author | Jenkins <jenkins@review.openstack.org> | 2016-01-06 05:54:00 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2016-01-06 05:54:00 +0000 |
| commit | ac5df4aa1ffc2aaeb2f35472fa2b3b969f4e07a6 (patch) | |
| tree | 00698fd9a97bbf95aa9406bb146fff483778e4a2 | |
| parent | 2df8593faad13b64038038de756ec0696967c989 (diff) | |
| parent | f5bcd87e238de8fdccb4da8e97373352fad474c6 (diff) | |
| download | python-keystoneclient-ac5df4aa1ffc2aaeb2f35472fa2b3b969f4e07a6.tar.gz | |
Merge "Implements base classes for functional tests"
| -rw-r--r-- | keystoneclient/tests/functional/base.py | 59 | ||||
| -rw-r--r-- | keystoneclient/tests/functional/test_base.py | 28 | ||||
| -rw-r--r-- | keystoneclient/tests/functional/v2_0/__init__.py | 0 | ||||
| -rw-r--r-- | keystoneclient/tests/functional/v3/__init__.py | 0 |
4 files changed, 87 insertions, 0 deletions
diff --git a/keystoneclient/tests/functional/base.py b/keystoneclient/tests/functional/base.py new file mode 100644 index 0000000..11fa567 --- /dev/null +++ b/keystoneclient/tests/functional/base.py @@ -0,0 +1,59 @@ +# 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 testtools + +from keystoneclient import client +import os_client_config + + +class ClientTestCase(testtools.TestCase): + + def setUp(self): + super(ClientTestCase, self).setUp() + + self.client = self.get_client() + + def get_client(self): + """Creates a keystoneclient instance to run functional tests + + The client is instantiated via os-client-config either based on a + clouds.yaml config file or from the environment variables. + + First, look for a 'functional_admin' cloud, as this is a cloud that the + user may have defined for functional testing with admin credentials. If + that is not found, check for the 'devstack-admin' cloud. Finally, fall + back to looking for environment variables. + + """ + IDENTITY_CLIENT = 'identity' + OPENSTACK_CLOUDS = ('functional_admin', 'devstack-admin', 'envvars') + + for cloud in OPENSTACK_CLOUDS: + try: + return os_client_config.make_client( + IDENTITY_CLIENT, client.Client, cloud=cloud, + identity_api_version=self.version) + except os_client_config.exceptions.OpenStackConfigException: + pass + + raise Exception("Could not find any cloud definition for clouds named" + " functional_admin or devstack-admin. Check your" + " clouds.yaml file or your envvars and try again.") + + +class V3ClientTestCase(ClientTestCase): + version = '3' + + +class V2ClientTestCase(ClientTestCase): + version = '2.0' diff --git a/keystoneclient/tests/functional/test_base.py b/keystoneclient/tests/functional/test_base.py new file mode 100644 index 0000000..d5f0516 --- /dev/null +++ b/keystoneclient/tests/functional/test_base.py @@ -0,0 +1,28 @@ +# 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 keystoneclient +from keystoneclient.tests.functional import base + + +class V3ClientVersionTestCase(base.V3ClientTestCase): + + def test_version(self): + self.assertIsInstance(self.client, + keystoneclient.v3.client.Client) + + +class V2ClientVersionTestCase(base.V2ClientTestCase): + + def test_version(self): + self.assertIsInstance(self.client, + keystoneclient.v2_0.client.Client) diff --git a/keystoneclient/tests/functional/v2_0/__init__.py b/keystoneclient/tests/functional/v2_0/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/keystoneclient/tests/functional/v2_0/__init__.py diff --git a/keystoneclient/tests/functional/v3/__init__.py b/keystoneclient/tests/functional/v3/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/keystoneclient/tests/functional/v3/__init__.py |
