summaryrefslogtreecommitdiff
path: root/openstackclient/tests/identity
diff options
context:
space:
mode:
authorHuanxuan Ao <huanxuan.ao@easystack.cn>2016-06-03 20:58:23 +0800
committerHuanxuan Ao <huanxuan.ao@easystack.cn>2016-06-07 16:17:42 +0800
commit0fd3a8c7877a8a04cd3234f2b44b7dd3117e2a80 (patch)
treee0096fa4886047585c9d406956221ae9e543a964 /openstackclient/tests/identity
parent5293bb103e75542d9defb9d0d5ed3c144f0657fe (diff)
downloadpython-openstackclient-0fd3a8c7877a8a04cd3234f2b44b7dd3117e2a80.tar.gz
Update unit test test_extension with fake class
Add FakeExtension class in networkv2, computev2, volumev2, identityv2_0 and update unit test test/common/test_extension.py Change-Id: I94815de7801860edb7fa91a7d146455cab946652
Diffstat (limited to 'openstackclient/tests/identity')
-rw-r--r--openstackclient/tests/identity/v2_0/fakes.py58
1 files changed, 38 insertions, 20 deletions
diff --git a/openstackclient/tests/identity/v2_0/fakes.py b/openstackclient/tests/identity/v2_0/fakes.py
index b37bd9da..b8093872 100644
--- a/openstackclient/tests/identity/v2_0/fakes.py
+++ b/openstackclient/tests/identity/v2_0/fakes.py
@@ -13,7 +13,9 @@
# under the License.
#
+import copy
import mock
+import uuid
from openstackclient.tests import fakes
from openstackclient.tests import utils
@@ -106,26 +108,6 @@ ENDPOINT = {
'service_id': endpoint_service_id,
}
-extension_name = 'OpenStack Keystone User CRUD'
-extension_namespace = 'http://docs.openstack.org/identity/'\
- 'api/ext/OS-KSCRUD/v1.0'
-extension_description = 'OpenStack extensions to Keystone v2.0 API'\
- ' enabling User Operations.'
-extension_updated = '2013-07-07T12:00:0-00:00'
-extension_alias = 'OS-KSCRUD'
-extension_links = '[{"href":'\
- '"https://github.com/openstack/identity-api", "type":'\
- ' "text/html", "rel": "describedby"}]'
-
-EXTENSION = {
- 'name': extension_name,
- 'namespace': extension_namespace,
- 'description': extension_description,
- 'updated': extension_updated,
- 'alias': extension_alias,
- 'links': extension_links,
-}
-
class FakeIdentityv2Client(object):
@@ -166,3 +148,39 @@ class TestIdentityv2(utils.TestCommand):
endpoint=fakes.AUTH_URL,
token=fakes.AUTH_TOKEN,
)
+
+
+class FakeExtension(object):
+ """Fake one or more extension."""
+
+ @staticmethod
+ def create_one_extension(attrs=None):
+ """Create a fake extension.
+
+ :param Dictionary attrs:
+ A dictionary with all attributes
+ :return:
+ A FakeResource object with name, namespace, etc.
+ """
+ attrs = attrs or {}
+
+ # Set default attributes.
+ extension_info = {
+ 'name': 'name-' + uuid.uuid4().hex,
+ 'namespace': ('http://docs.openstack.org/identity/'
+ 'api/ext/OS-KSCRUD/v1.0'),
+ 'description': 'description-' + uuid.uuid4().hex,
+ 'updated': '2013-07-07T12:00:0-00:00',
+ 'alias': 'OS-KSCRUD',
+ 'links': ('[{"href":'
+ '"https://github.com/openstack/identity-api", "type":'
+ ' "text/html", "rel": "describedby"}]')
+ }
+
+ # Overwrite default attributes.
+ extension_info.update(attrs)
+
+ extension = fakes.FakeResource(
+ info=copy.deepcopy(extension_info),
+ loaded=True)
+ return extension