1616
1717from openstack .compute .v2 import flavor as _flavor
1818from openstack import exceptions as sdk_exceptions
19- from openstack import utils as sdk_utils
2019from osc_lib .cli import format_columns
2120from osc_lib import exceptions
2221
@@ -118,6 +117,8 @@ def test_flavor_create_default_options(self):
118117 self .assertCountEqual (self .data , data )
119118
120119 def test_flavor_create_all_options (self ):
120+ self .set_compute_api_version ('2.55' )
121+
121122 arglist = [
122123 '--id' ,
123124 self .flavor .id ,
@@ -184,22 +185,19 @@ def test_flavor_create_all_options(self):
184185 expected_flavor
185186 )
186187
187- with mock .patch .object (
188- sdk_utils , 'supports_microversion' , return_value = True
189- ):
190- columns , data = self .cmd .take_action (parsed_args )
191- self .compute_sdk_client .create_flavor .assert_called_once_with (
192- ** args
193- )
194- self .compute_sdk_client .create_flavor_extra_specs .assert_called_once_with (
195- create_flavor , props
196- )
197- self .compute_sdk_client .get_flavor_access .assert_not_called ()
188+ columns , data = self .cmd .take_action (parsed_args )
189+ self .compute_sdk_client .create_flavor .assert_called_once_with (** args )
190+ self .compute_sdk_client .create_flavor_extra_specs .assert_called_once_with (
191+ create_flavor , props
192+ )
193+ self .compute_sdk_client .get_flavor_access .assert_not_called ()
198194
199195 self .assertEqual (self .columns , columns )
200196 self .assertCountEqual (tuple (cmp_data ), data )
201197
202198 def test_flavor_create_other_options (self ):
199+ self .set_compute_api_version ('2.55' )
200+
203201 self .flavor .is_public = False
204202 arglist = [
205203 '--id' ,
@@ -272,10 +270,8 @@ def test_flavor_create_other_options(self):
272270 expected_flavor
273271 )
274272
275- with mock .patch .object (
276- sdk_utils , 'supports_microversion' , return_value = True
277- ):
278- columns , data = self .cmd .take_action (parsed_args )
273+ columns , data = self .cmd .take_action (parsed_args )
274+
279275 self .compute_sdk_client .create_flavor .assert_called_once_with (** args )
280276 self .compute_sdk_client .flavor_add_tenant_access .assert_called_with (
281277 self .flavor .id ,
@@ -314,7 +310,9 @@ def test_flavor_create_no_options(self):
314310 verifylist ,
315311 )
316312
317- def test_flavor_create_with_description_api_newer (self ):
313+ def test_flavor_create_with_description (self ):
314+ self .set_compute_api_version ('2.55' )
315+
318316 arglist = [
319317 '--id' ,
320318 self .flavor .id ,
@@ -348,10 +346,8 @@ def test_flavor_create_with_description_api_newer(self):
348346 ('name' , self .flavor .name ),
349347 ]
350348 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
351- with mock .patch .object (
352- sdk_utils , 'supports_microversion' , return_value = True
353- ):
354- columns , data = self .cmd .take_action (parsed_args )
349+
350+ columns , data = self .cmd .take_action (parsed_args )
355351
356352 args = {
357353 'name' : self .flavor .name ,
@@ -371,7 +367,9 @@ def test_flavor_create_with_description_api_newer(self):
371367 self .assertEqual (self .columns , columns )
372368 self .assertCountEqual (self .data_private , data )
373369
374- def test_flavor_create_with_description_api_older (self ):
370+ def test_flavor_create_with_description_pre_v255 (self ):
371+ self .set_compute_api_version ('2.54' )
372+
375373 arglist = [
376374 '--id' ,
377375 self .flavor .id ,
@@ -391,12 +389,9 @@ def test_flavor_create_with_description_api_older(self):
391389 ]
392390 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
393391
394- with mock .patch .object (
395- sdk_utils , 'supports_microversion' , return_value = False
396- ):
397- self .assertRaises (
398- exceptions .CommandError , self .cmd .take_action , parsed_args
399- )
392+ self .assertRaises (
393+ exceptions .CommandError , self .cmd .take_action , parsed_args
394+ )
400395
401396
402397class TestFlavorDelete (TestFlavor ):
@@ -887,7 +882,9 @@ def test_flavor_set_nothing(self):
887882 self .compute_sdk_client .flavor_add_tenant_access .assert_not_called ()
888883 self .assertIsNone (result )
889884
890- def test_flavor_set_description_api_newer (self ):
885+ def test_flavor_set_description (self ):
886+ self .set_compute_api_version ('2.55' )
887+
891888 arglist = [
892889 '--description' ,
893890 'description' ,
@@ -899,16 +896,15 @@ def test_flavor_set_description_api_newer(self):
899896 ]
900897 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
901898
902- with mock . patch . object (
903- sdk_utils , 'supports_microversion' , return_value = True
904- ):
905- result = self . cmd . take_action ( parsed_args )
906- self .compute_sdk_client . update_flavor . assert_called_with (
907- flavor = self . flavor . id , description = 'description'
908- )
909- self .assertIsNone ( result )
899+ result = self . cmd . take_action ( parsed_args )
900+ self . compute_sdk_client . update_flavor . assert_called_with (
901+ flavor = self . flavor . id , description = 'description'
902+ )
903+ self .assertIsNone ( result )
904+
905+ def test_flavor_set_description_pre_v254 ( self ):
906+ self .set_compute_api_version ( '2.54' )
910907
911- def test_flavor_set_description_api_older (self ):
912908 arglist = [
913909 '--description' ,
914910 'description' ,
@@ -920,14 +916,13 @@ def test_flavor_set_description_api_older(self):
920916 ]
921917 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
922918
923- with mock . patch . object (
924- sdk_utils , 'supports_microversion' , return_value = False
925- ):
926- self . assertRaises (
927- exceptions . CommandError , self . cmd . take_action , parsed_args
928- )
919+ self . assertRaises (
920+ exceptions . CommandError , self . cmd . take_action , parsed_args
921+ )
922+
923+ def test_flavor_set_description_using_name ( self ):
924+ self . set_compute_api_version ( '2.55' )
929925
930- def test_flavor_set_description_using_name_api_newer (self ):
931926 arglist = [
932927 '--description' ,
933928 'description' ,
@@ -939,16 +934,15 @@ def test_flavor_set_description_using_name_api_newer(self):
939934 ]
940935 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
941936
942- with mock . patch . object (
943- sdk_utils , 'supports_microversion' , return_value = True
944- ):
945- result = self . cmd . take_action ( parsed_args )
946- self .compute_sdk_client . update_flavor . assert_called_with (
947- flavor = self . flavor . id , description = 'description'
948- )
949- self .assertIsNone ( result )
937+ result = self . cmd . take_action ( parsed_args )
938+ self . compute_sdk_client . update_flavor . assert_called_with (
939+ flavor = self . flavor . id , description = 'description'
940+ )
941+ self .assertIsNone ( result )
942+
943+ def test_flavor_set_description_using_name_pre_v255 ( self ):
944+ self .set_compute_api_version ( '2.54' )
950945
951- def test_flavor_set_description_using_name_api_older (self ):
952946 arglist = [
953947 '--description' ,
954948 'description' ,
@@ -960,12 +954,9 @@ def test_flavor_set_description_using_name_api_older(self):
960954 ]
961955 parsed_args = self .check_parser (self .cmd , arglist , verifylist )
962956
963- with mock .patch .object (
964- sdk_utils , 'supports_microversion' , return_value = False
965- ):
966- self .assertRaises (
967- exceptions .CommandError , self .cmd .take_action , parsed_args
968- )
957+ self .assertRaises (
958+ exceptions .CommandError , self .cmd .take_action , parsed_args
959+ )
969960
970961
971962class TestFlavorShow (TestFlavor ):
0 commit comments