@@ -4052,6 +4052,8 @@ def test_show_image_properties_unknown_failure(
40524052 image_property = 'hw_disk_bus' )
40534053 self .assertEqual (1 , ret , 'return code' )
40544054
4055+ @mock .patch ('nova.objects.RequestSpec.save' )
4056+ @mock .patch ('nova.objects.RequestSpec.get_by_instance_uuid' )
40554057 @mock .patch ('nova.objects.Instance.get_by_uuid' )
40564058 @mock .patch ('nova.context.target_cell' )
40574059 @mock .patch ('nova.objects.Instance.save' )
@@ -4060,7 +4062,8 @@ def test_show_image_properties_unknown_failure(
40604062 @mock .patch ('nova.context.get_admin_context' ,
40614063 new = mock .Mock (return_value = mock .sentinel .ctxt ))
40624064 def test_set_image_properties (
4063- self , mock_instance_save , mock_target_cell , mock_get_instance
4065+ self , mock_instance_save , mock_target_cell , mock_get_instance ,
4066+ mock_get_request_spec , mock_request_spec_save
40644067 ):
40654068 mock_target_cell .return_value .__enter__ .return_value = \
40664069 mock .sentinel .cctxt
@@ -4069,9 +4072,11 @@ def test_set_image_properties(
40694072 vm_state = obj_fields .InstanceState .STOPPED ,
40704073 system_metadata = {
40714074 'image_hw_disk_bus' : 'virtio' ,
4072- }
4075+ },
4076+ image_ref = ''
40734077 )
40744078 mock_get_instance .return_value = instance
4079+ mock_get_request_spec .return_value = objects .RequestSpec ()
40754080 ret = self .commands .set (
40764081 instance_uuid = uuidsentinel .instance ,
40774082 image_properties = ['hw_cdrom_bus=sata' ]
@@ -4088,7 +4093,12 @@ def test_set_image_properties(
40884093 instance .system_metadata .get ('image_hw_disk_bus' ),
40894094 'image_hw_disk_bus'
40904095 )
4096+ image_props = mock_get_request_spec .return_value .image .properties
4097+ self .assertEqual ('sata' , image_props .get ('hw_cdrom_bus' ))
4098+ self .assertEqual ('virtio' , image_props .get ('hw_disk_bus' ))
4099+
40914100 mock_instance_save .assert_called_once ()
4101+ mock_request_spec_save .assert_called_once ()
40924102
40934103 @mock .patch ('nova.objects.Instance.get_by_uuid' )
40944104 @mock .patch ('nova.objects.InstanceMapping.get_by_instance_uuid' ,
0 commit comments