Updated fixture and test for error message clarity.
Change-Id: Iba0b682403e9bb1ec57d9d493475c3b48a80c0a3
This commit is contained in:
parent
96f456d1e1
commit
4241d2d29c
|
@ -172,14 +172,31 @@ class VolumesTestFixture(BaseVolumesTestFixture):
|
|||
|
||||
error_messages = []
|
||||
for attr in comparable_attrs:
|
||||
attr1 = getattr(volume1, attr, None)
|
||||
attr2 = getattr(volume2, attr, None)
|
||||
if attr1 != attr2:
|
||||
error_messages.append(
|
||||
"\n'{attr}' differs for volumes {v0} and {v1}. ({attr1} "
|
||||
"!= {attr2})".format(
|
||||
attr=attr, v0=volume1.id_, v1=volume2.id_,
|
||||
attr1=attr1, attr2=attr2))
|
||||
in_vol1 = hasattr(volume1, attr)
|
||||
in_vol2 = hasattr(volume2, attr)
|
||||
if in_vol1 and in_vol2:
|
||||
attr1 = getattr(volume1, attr, None)
|
||||
attr2 = getattr(volume2, attr, None)
|
||||
if attr1 != attr2:
|
||||
error_messages.append(
|
||||
"\n'{attr}' differs for volumes {v0} and {v1}. "
|
||||
"({attr1} != {attr2})".format(
|
||||
attr=attr, v0=volume1.id_, v1=volume2.id_,
|
||||
attr1=attr1, attr2=attr2))
|
||||
else:
|
||||
if not in_vol1 and in_vol2:
|
||||
error_messages.append(
|
||||
"\n'{attr}' is present in {v0} but not in {v1}."
|
||||
.format(attr=attr, v0=volume1.id_, v1=volume2.id_))
|
||||
elif in_vol1 and not in_vol2:
|
||||
error_messages.append(
|
||||
"\n'{attr}' is present in {v1} but not in {v0}."
|
||||
.format(attr=attr, v0=volume1.id_, v1=volume2.id_))
|
||||
elif not in_vol1 and not in_vol2:
|
||||
error_messages.append(
|
||||
"\n'{attr}' is not present in {v0} or {v1}, "
|
||||
"but is expected to be.".format(
|
||||
attr=attr, v0=volume1.id_, v1=volume2.id_))
|
||||
|
||||
if 'metadata' in comparable_attrs:
|
||||
error_messages.extend(
|
||||
|
|
|
@ -223,7 +223,8 @@ class VolumeActions(VolumesTestFixture):
|
|||
volume_info = expected_volumes[0]
|
||||
|
||||
# Test
|
||||
self.assertVolumeAttributesAreEqual(volume, volume_info)
|
||||
self.assertVolumeAttributesAreEqual(
|
||||
volume, volume_info, excluded_attrs_list=['volume_image_metadata'])
|
||||
|
||||
@data_driven_test(volume_types_dataset)
|
||||
@tags('volumes', 'smoke')
|
||||
|
|
Loading…
Reference in New Issue