@@ -269,6 +269,10 @@ def setUp(self):
269
269
labels = {'key1' : 'val1' , 'key2' : 'val2' },
270
270
hidden = False
271
271
)
272
+ p = mock .patch .object (
273
+ attr_validator , 'validate_flavor_root_volume_size' )
274
+ self .mock_valid_flavor_disk = p .start ()
275
+ self .addCleanup (p .stop )
272
276
273
277
def test_update_not_found (self ):
274
278
uuid = uuidutils .generate_uuid ()
@@ -482,6 +486,19 @@ def test_replace_cluster_template_with_no_exist_flavor_id(self):
482
486
self .assertEqual (400 , response .status_code )
483
487
self .assertTrue (response .json ['errors' ])
484
488
489
+ def test_replace_cluster_template_with_invalid_flavor (self ):
490
+ self .mock_valid_flavor_disk .side_effect = \
491
+ exception .FlavorZeroRootVolumeNotSupported ()
492
+ response = self .patch_json ('/clustertemplates/%s' %
493
+ self .cluster_template .uuid ,
494
+ [{'path' : '/flavor_id' , 'value' : 'aaa' ,
495
+ 'op' : 'replace' }],
496
+ expect_errors = True )
497
+ self .assertEqual ('application/json' , response .content_type )
498
+ self .assertEqual (400 , response .status_code )
499
+ self .assertTrue (self .mock_valid_flavor_disk .called )
500
+ self .assertTrue (response .json ['errors' ])
501
+
485
502
def test_replace_cluster_template_with_no_exist_keypair_id (self ):
486
503
self .mock_valid_os_res .side_effect = exception .KeyPairNotFound ("aaa" )
487
504
response = self .patch_json ('/clustertemplates/%s' %
@@ -632,6 +649,10 @@ def setUp(self):
632
649
p = mock .patch .object (attr_validator , 'validate_os_resources' )
633
650
self .mock_valid_os_res = p .start ()
634
651
self .addCleanup (p .stop )
652
+ p = mock .patch .object (
653
+ attr_validator , 'validate_flavor_root_volume_size' )
654
+ self .mock_valid_flavor_disk = p .start ()
655
+ self .addCleanup (p .stop )
635
656
636
657
@mock .patch ('magnum.api.attr_validator.validate_image' )
637
658
@mock .patch ('oslo_utils.timeutils.utcnow' )
@@ -1110,6 +1131,21 @@ def test_create_cluster_template_with_no_exist_flavor(self,
1110
1131
expect_errors = True )
1111
1132
self .assertEqual (400 , response .status_int )
1112
1133
1134
+ @mock .patch ('magnum.api.attr_validator.validate_image' )
1135
+ def test_create_cluster_template_with_invalid_flavor (
1136
+ self ,
1137
+ mock_image_data
1138
+ ):
1139
+ self .mock_valid_flavor_disk .side_effect = \
1140
+ exception .FlavorZeroRootVolumeNotSupported ()
1141
+ mock_image_data .return_value = {'name' : 'mock_name' ,
1142
+ 'os_distro' : 'fedora-coreos' }
1143
+ bdict = apiutils .cluster_template_post_data ()
1144
+ response = self .post_json ('/clustertemplates' , bdict ,
1145
+ expect_errors = True )
1146
+ self .assertTrue (self .mock_valid_flavor_disk .called )
1147
+ self .assertEqual (400 , response .status_int )
1148
+
1113
1149
@mock .patch ('magnum.api.attr_validator.validate_image' )
1114
1150
def test_create_cluster_template_with_external_network (self ,
1115
1151
mock_image_data ):
0 commit comments