Skip to content

Commit 95f0e3d

Browse files
author
Huanxuan Ao
committed
Fix errors in volume set/unset image properties unit tests
These errors may caused by copy-paste, we should specify a fake return value for get() method but not create() method. Create() mothod will not called in set/unset command. After specifing the return value of get(), we can use the fake volume in the assert. Change-Id: I1e0df4c28ece373168788c396e9082d565e36cc7
1 parent b3248fb commit 95f0e3d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

openstackclient/tests/volume/v2/test_volume.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ def test_volume_set_image_property(self):
841841
# returns nothing
842842
self.cmd.take_action(parsed_args)
843843
self.volumes_mock.set_image_metadata.assert_called_with(
844-
self.volumes_mock.get().id, parsed_args.image_property)
844+
self.new_volume.id, parsed_args.image_property)
845845

846846
def test_volume_set_state(self):
847847
arglist = [
@@ -919,7 +919,7 @@ def setUp(self):
919919
super(TestVolumeUnset, self).setUp()
920920

921921
self.new_volume = volume_fakes.FakeVolume.create_one_volume()
922-
self.volumes_mock.create.return_value = self.new_volume
922+
self.volumes_mock.get.return_value = self.new_volume
923923

924924
# Get the command object to set property
925925
self.cmd_set = volume.SetVolume(self.app, None)
@@ -963,4 +963,4 @@ def test_volume_unset_image_property(self):
963963
self.cmd_unset.take_action(parsed_args_unset)
964964

965965
self.volumes_mock.delete_image_metadata.assert_called_with(
966-
self.volumes_mock.get().id, parsed_args_unset.image_property)
966+
self.new_volume.id, parsed_args_unset.image_property)

0 commit comments

Comments
 (0)