]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add kwargs to create_volume in tests/utils.py
authorJulia Varlamova <jvarlamova@mirantis.com>
Thu, 29 Aug 2013 07:41:34 +0000 (11:41 +0400)
committerJulia Varlamova <jvarlamova@mirantis.com>
Thu, 29 Aug 2013 08:17:15 +0000 (12:17 +0400)
Add availability_zone parameter and kwargs to make create_volume
function more flexible in order to use this function in
unit tests.
The goal is to remove inner _create_volume function in:
- db/test_transfers.py
- api/contrib/test_backups.py
- test_gpfs.py
- test_volume_transfer.py
- test_volume.py
and to use create_volume from tests/utils instead.

Change-Id: I2d9456ff3ff1cd945042f19c47e40f9f0ec0fe8a

cinder/tests/utils.py

index 25e34513f99edac1e71c86273cba20f592ba15af..c623f3e7de0df706ba1fddb900073de17b108b5b 100644 (file)
@@ -32,7 +32,9 @@ def create_volume(ctxt,
                   display_description='this is a test volume',
                   status='available',
                   migration_status=None,
-                  size=1):
+                  size=1,
+                  availability_zone='fake_az',
+                  **kwargs):
     """Create a volume object in the DB."""
     vol = {}
     vol['size'] = size
@@ -44,6 +46,9 @@ def create_volume(ctxt,
     vol['display_name'] = display_name
     vol['display_description'] = display_description
     vol['attach_status'] = 'detached'
+    vol['availability_zone'] = availability_zone
+    for key in kwargs:
+        vol[key] = kwargs[key]
     return db.volume_create(ctxt, vol)