Skip to content

Commit 4a8b802

Browse files
author
Huanxuan Ao
committed
Refactor volume unit test with FakeVolume class in volume v1
FakeVolume class has been added in the fake.py in volume v1, this patch refactors the volume command unit tests with the FakeVolume class. Change-Id: Ic3c1a46d5bff9048d0095f5739ae9e5a34ca6b5b
1 parent ccd2d65 commit 4a8b802

2 files changed

Lines changed: 131 additions & 136 deletions

File tree

openstackclient/tests/unit/volume/v1/fakes.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,24 +363,24 @@ def create_one_volume(attrs=None):
363363
# Set default attribute
364364
volume_info = {
365365
'id': 'volume-id' + uuid.uuid4().hex,
366-
'name': 'volume-name' + uuid.uuid4().hex,
367-
'description': 'description' + uuid.uuid4().hex,
368-
'status': random.choice(['available', 'in_use']),
369-
'size': random.randint(1, 20),
366+
'display_name': 'volume-name' + uuid.uuid4().hex,
367+
'display_description': 'description' + uuid.uuid4().hex,
368+
'status': 'available',
369+
'size': 10,
370370
'volume_type':
371371
random.choice(['fake_lvmdriver-1', 'fake_lvmdriver-2']),
372-
'bootable':
373-
random.randint(0, 1),
372+
'bootable': 'true',
374373
'metadata': {
375374
'key' + uuid.uuid4().hex: 'val' + uuid.uuid4().hex,
376375
'key' + uuid.uuid4().hex: 'val' + uuid.uuid4().hex,
377376
'key' + uuid.uuid4().hex: 'val' + uuid.uuid4().hex},
378-
'snapshot_id': random.randint(1, 5),
377+
'snapshot_id': 'snapshot-id-' + uuid.uuid4().hex,
379378
'availability_zone': 'zone' + uuid.uuid4().hex,
380379
'attachments': [{
381380
'device': '/dev/' + uuid.uuid4().hex,
382381
'server_id': uuid.uuid4().hex,
383382
}, ],
383+
'created_at': 'time-' + uuid.uuid4().hex,
384384
}
385385

386386
# Overwrite default attributes if there are some attributes set

0 commit comments

Comments
 (0)