@@ -1012,9 +1012,7 @@ def test_update_v21(self, mock_create):
1012
1012
}
1013
1013
}
1014
1014
self .assertEqual (expected_response , response )
1015
- mock_create .assert_called_once_with (req .environ ['nova.context' ],
1016
- uuids .project_id , "server_groups" ,
1017
- 2 , user_id = None )
1015
+ self .assertEqual (0 , mock_create .call_count )
1018
1016
1019
1017
@mock .patch .object (objects .Quotas , "create_limit" )
1020
1018
def test_update_v21_user (self , mock_create ):
@@ -1040,6 +1038,75 @@ def test_update_v21_user(self, mock_create):
1040
1038
}
1041
1039
}
1042
1040
self .assertEqual (expected_response , response )
1043
- mock_create .assert_called_once_with (req .environ ['nova.context' ],
1044
- uuids .project_id , "key_pairs" , 52 ,
1045
- user_id = "42" )
1041
+ self .assertEqual (0 , mock_create .call_count )
1042
+
1043
+ def test_defaults_v21 (self ):
1044
+ req = fakes .HTTPRequest .blank ("" )
1045
+ response = self .controller .defaults (req , uuids .project_id )
1046
+ expected_response = {
1047
+ 'quota_set' : {
1048
+ 'id' : uuids .project_id ,
1049
+ 'cores' : - 1 ,
1050
+ 'fixed_ips' : - 1 ,
1051
+ 'floating_ips' : - 1 ,
1052
+ 'injected_file_content_bytes' : 10240 ,
1053
+ 'injected_file_path_bytes' : 255 ,
1054
+ 'injected_files' : 5 ,
1055
+ 'instances' : - 1 ,
1056
+ 'key_pairs' : 100 ,
1057
+ 'metadata_items' : 128 ,
1058
+ 'ram' : - 1 ,
1059
+ 'security_group_rules' : - 1 ,
1060
+ 'security_groups' : - 1 ,
1061
+ 'server_group_members' : 10 ,
1062
+ 'server_groups' : 12 ,
1063
+ }
1064
+ }
1065
+ self .assertEqual (expected_response , response )
1066
+
1067
+ def test_defaults_v21_different_limit_values (self ):
1068
+ reglimits = {local_limit .SERVER_METADATA_ITEMS : 7 ,
1069
+ local_limit .INJECTED_FILES : 6 ,
1070
+ local_limit .INJECTED_FILES_CONTENT : 4 ,
1071
+ local_limit .INJECTED_FILES_PATH : 5 ,
1072
+ local_limit .KEY_PAIRS : 1 ,
1073
+ local_limit .SERVER_GROUPS : 3 ,
1074
+ local_limit .SERVER_GROUP_MEMBERS : 2 }
1075
+ self .useFixture (limit_fixture .LimitFixture (reglimits , {}))
1076
+
1077
+ req = fakes .HTTPRequest .blank ("" )
1078
+ response = self .controller .defaults (req , uuids .project_id )
1079
+ expected_response = {
1080
+ 'quota_set' : {
1081
+ 'id' : uuids .project_id ,
1082
+ 'cores' : - 1 ,
1083
+ 'fixed_ips' : - 1 ,
1084
+ 'floating_ips' : - 1 ,
1085
+ 'injected_file_content_bytes' : 4 ,
1086
+ 'injected_file_path_bytes' : 5 ,
1087
+ 'injected_files' : 6 ,
1088
+ 'instances' : - 1 ,
1089
+ 'key_pairs' : 1 ,
1090
+ 'metadata_items' : 7 ,
1091
+ 'ram' : - 1 ,
1092
+ 'security_group_rules' : - 1 ,
1093
+ 'security_groups' : - 1 ,
1094
+ 'server_group_members' : 2 ,
1095
+ 'server_groups' : 3 ,
1096
+ }
1097
+ }
1098
+ self .assertEqual (expected_response , response )
1099
+
1100
+ @mock .patch ('nova.objects.Quotas.destroy_all_by_project' )
1101
+ def test_quotas_delete (self , mock_destroy_all_by_project ):
1102
+ req = fakes .HTTPRequest .blank ("" )
1103
+ self .controller .delete (req , "1234" )
1104
+ # Ensure destroy isn't called for unified limits
1105
+ self .assertEqual (0 , mock_destroy_all_by_project .call_count )
1106
+
1107
+ @mock .patch ('nova.objects.Quotas.destroy_all_by_project_and_user' )
1108
+ def test_user_quotas_delete (self , mock_destroy_all_by_user ):
1109
+ req = fakes .HTTPRequest .blank ("?user_id=42" )
1110
+ self .controller .delete (req , "1234" )
1111
+ # Ensure destroy isn't called for unified limits
1112
+ self .assertEqual (0 , mock_destroy_all_by_user .call_count )
0 commit comments