2020from osc_lib import utils
2121
2222from openstackclient .tests .unit .identity .v3 import fakes as project_fakes
23+ from openstackclient .tests .unit import utils as tests_utils
2324from openstackclient .tests .unit .volume .v2 import fakes as volume_fakes
2425from openstackclient .volume .v2 import volume_snapshot
2526
@@ -107,27 +108,17 @@ def test_snapshot_create(self):
107108 def test_snapshot_create_without_name (self ):
108109 arglist = [
109110 "--volume" , self .new_snapshot .volume_id ,
110- "--description" , self .new_snapshot .description ,
111- "--force"
112111 ]
113112 verifylist = [
114113 ("volume" , self .new_snapshot .volume_id ),
115- ("description" , self .new_snapshot .description ),
116- ("force" , True )
117114 ]
118- parsed_args = self .check_parser (self .cmd , arglist , verifylist )
119-
120- columns , data = self .cmd .take_action (parsed_args )
121-
122- self .snapshots_mock .create .assert_called_with (
123- self .new_snapshot .volume_id ,
124- force = True ,
125- name = None ,
126- description = self .new_snapshot .description ,
127- metadata = None ,
115+ self .assertRaises (
116+ tests_utils .ParserException ,
117+ self .check_parser ,
118+ self .cmd ,
119+ arglist ,
120+ verifylist ,
128121 )
129- self .assertEqual (self .columns , columns )
130- self .assertEqual (self .data , data )
131122
132123 def test_snapshot_create_without_volume (self ):
133124 arglist = [
@@ -156,17 +147,19 @@ def test_snapshot_create_without_volume(self):
156147 self .assertEqual (self .columns , columns )
157148 self .assertEqual (self .data , data )
158149
159- def test_snapshot_create_without_remote_source (self ):
150+ def test_snapshot_create_with_remote_source (self ):
160151 arglist = [
161152 '--remote-source' , 'source-name=test_source_name' ,
162153 '--remote-source' , 'source-id=test_source_id' ,
163154 '--volume' , self .new_snapshot .volume_id ,
155+ self .new_snapshot .name ,
164156 ]
165157 ref_dict = {'source-name' : 'test_source_name' ,
166158 'source-id' : 'test_source_id' }
167159 verifylist = [
168160 ('remote_source' , ref_dict ),
169161 ('volume' , self .new_snapshot .volume_id ),
162+ ("snapshot_name" , self .new_snapshot .name ),
170163 ]
171164 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
172165
@@ -175,7 +168,7 @@ def test_snapshot_create_without_remote_source(self):
175168 self .snapshots_mock .manage .assert_called_with (
176169 volume_id = self .new_snapshot .volume_id ,
177170 ref = ref_dict ,
178- name = None ,
171+ name = self . new_snapshot . name ,
179172 description = None ,
180173 metadata = None ,
181174 )
0 commit comments