@@ -376,6 +376,55 @@ def test_snapshot_set_state_to_error(self):
376376 self .snapshot .id , "error" )
377377 self .assertIsNone (result )
378378
379+ def test_volume_set_state_failed (self ):
380+ self .snapshots_mock .reset_state .side_effect = exceptions .CommandError ()
381+ arglist = [
382+ '--state' , 'error' ,
383+ self .snapshot .id
384+ ]
385+ verifylist = [
386+ ('state' , 'error' ),
387+ ('snapshot' , self .snapshot .id )
388+ ]
389+
390+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
391+ try :
392+ self .cmd .take_action (parsed_args )
393+ self .fail ('CommandError should be raised.' )
394+ except exceptions .CommandError as e :
395+ self .assertEqual ('One or more of the set operations failed' ,
396+ str (e ))
397+ self .snapshots_mock .reset_state .assert_called_once_with (
398+ self .snapshot .id , 'error' )
399+
400+ def test_volume_set_name_and_state_failed (self ):
401+ self .snapshots_mock .reset_state .side_effect = exceptions .CommandError ()
402+ arglist = [
403+ '--state' , 'error' ,
404+ "--name" , "new_snapshot" ,
405+ self .snapshot .id
406+ ]
407+ verifylist = [
408+ ('state' , 'error' ),
409+ ("name" , "new_snapshot" ),
410+ ('snapshot' , self .snapshot .id )
411+ ]
412+
413+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
414+ try :
415+ self .cmd .take_action (parsed_args )
416+ self .fail ('CommandError should be raised.' )
417+ except exceptions .CommandError as e :
418+ self .assertEqual ('One or more of the set operations failed' ,
419+ str (e ))
420+ kwargs = {
421+ "name" : "new_snapshot" ,
422+ }
423+ self .snapshots_mock .update .assert_called_once_with (
424+ self .snapshot .id , ** kwargs )
425+ self .snapshots_mock .reset_state .assert_called_once_with (
426+ self .snapshot .id , 'error' )
427+
379428
380429class TestSnapshotShow (TestSnapshot ):
381430
0 commit comments