@@ -1062,7 +1062,60 @@ def test_delete_manage_api_key(user_utils, requests_mock):
10621062 user_utils .delete_manage_api_key (apikey )
10631063 assert delete .call_count == 1
10641064
1065- # TODO: href_does_not_parse
1065+
1066+ def test_delete_manage_api_key_notfound (user_utils , requests_mock ):
1067+ user_id = "user1"
1068+ apikey_id = "theapikeyid"
1069+ apikey = {"userid" : user_id , "href" : f"https://{ MANAGE_API_URL } :{ MANAGE_API_PORT } /maximo/api/os/mxapiapikey/{ apikey_id } " }
1070+
1071+ delete = requests_mock .delete (
1072+ f"{ MANAGE_API_URL } /maximo/api/os/mxapiapikey/{ apikey_id } ?ccm=1&lean=1" ,
1073+ request_headers = {"accept" : "application/json" },
1074+ text = "notused" ,
1075+ status_code = 404 ,
1076+ additional_matcher = lambda req : additional_matcher (req , cert = PEM_PATH )
1077+ )
1078+
1079+ user_utils .delete_manage_api_key (apikey )
1080+ assert delete .call_count == 1
1081+
1082+
1083+ def test_delete_manage_api_key_bad_href (user_utils , requests_mock ):
1084+ user_id = "user1"
1085+ apikey_id = "theapikeyid"
1086+ apikey = {"userid" : user_id , "href" : f"notgood/{ apikey_id } " }
1087+
1088+ delete = requests_mock .delete (
1089+ f"{ MANAGE_API_URL } /maximo/api/os/mxapiapikey/{ apikey_id } ?ccm=1&lean=1" ,
1090+ request_headers = {"accept" : "application/json" },
1091+ text = "notused" ,
1092+ status_code = 204 ,
1093+ additional_matcher = lambda req : additional_matcher (req , cert = PEM_PATH )
1094+ )
1095+
1096+ with pytest .raises (Exception ) as excinfo :
1097+ user_utils .delete_manage_api_key (apikey )
1098+ assert str (excinfo .value ) == f"Could not parse API Key href: notgood/{ apikey_id } "
1099+ assert delete .call_count == 0
1100+
1101+
1102+ def test_delete_manage_api_key_error (user_utils , requests_mock ):
1103+ user_id = "user1"
1104+ apikey_id = "theapikeyid"
1105+ apikey = {"userid" : user_id , "href" : f"https://{ MANAGE_API_URL } :{ MANAGE_API_PORT } /maximo/api/os/mxapiapikey/{ apikey_id } " }
1106+
1107+ delete = requests_mock .delete (
1108+ f"{ MANAGE_API_URL } /maximo/api/os/mxapiapikey/{ apikey_id } ?ccm=1&lean=1" ,
1109+ request_headers = {"accept" : "application/json" },
1110+ text = "boom" ,
1111+ status_code = 500 ,
1112+ additional_matcher = lambda req : additional_matcher (req , cert = PEM_PATH )
1113+ )
1114+
1115+ with pytest .raises (Exception ) as excinfo :
1116+ user_utils .delete_manage_api_key (apikey )
1117+ assert str (excinfo .value ) == "500 boom"
1118+ assert delete .call_count == 1
10661119
10671120
10681121def test_get_manage_group_id (user_utils , requests_mock ):
0 commit comments