diff options
| author | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-06-03 20:58:23 +0800 |
|---|---|---|
| committer | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-06-07 16:17:42 +0800 |
| commit | 0fd3a8c7877a8a04cd3234f2b44b7dd3117e2a80 (patch) | |
| tree | e0096fa4886047585c9d406956221ae9e543a964 /openstackclient/tests/volume | |
| parent | 5293bb103e75542d9defb9d0d5ed3c144f0657fe (diff) | |
| download | python-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/volume')
| -rw-r--r-- | openstackclient/tests/volume/v2/fakes.py | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/openstackclient/tests/volume/v2/fakes.py b/openstackclient/tests/volume/v2/fakes.py index e61fe8aa..3571890a 100644 --- a/openstackclient/tests/volume/v2/fakes.py +++ b/openstackclient/tests/volume/v2/fakes.py @@ -211,26 +211,6 @@ IMAGE = { 'name': image_name } -extension_name = 'SchedulerHints' -extension_namespace = 'http://docs.openstack.org/'\ - 'block-service/ext/scheduler-hints/api/v2' -extension_description = 'Pass arbitrary key/value'\ - 'pairs to the scheduler.' -extension_updated = '2013-04-18T00:00:00+00:00' -extension_alias = 'OS-SCH-HNT' -extension_links = '[{"href":'\ - '"https://github.com/openstack/block-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 FakeTransferClient(object): @@ -379,6 +359,8 @@ class FakeVolumeClient(object): def __init__(self, **kwargs): self.volumes = mock.Mock() self.volumes.resource_class = fakes.FakeResource(None, {}) + self.extensions = mock.Mock() + self.extensions.resource_class = fakes.FakeResource(None, {}) self.volume_snapshots = mock.Mock() self.volume_snapshots.resource_class = fakes.FakeResource(None, {}) self.backups = mock.Mock() @@ -643,6 +625,42 @@ class FakeBackup(object): return backups +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/' + 'block-service/ext/scheduler-hints/api/v2'), + 'description': 'description-' + uuid.uuid4().hex, + 'updated': '2013-04-18T00:00:00+00:00', + 'alias': 'OS-SCH-HNT', + 'links': ('[{"href":' + '"https://github.com/openstack/block-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 + + class FakeQos(object): """Fake one or more Qos specification.""" |
