Skip to content

Commit caaad9f

Browse files
committed
unit tests
1 parent dbdcc9b commit caaad9f

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/mas/devops/users.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,7 @@ def delete_manage_api_key(self, manage_api_key):
615615
)
616616

617617
if response.status_code != 204 and response.status_code != 404:
618-
raise Exception(response.text)
619-
# {"Error":{"extendedError":{"moreInfo":{"href":"https:\/\/masdev.manage.tgk01.apps.noble4.cp.fyre.ibm.com\/maximo\/api\/error\/messages\/BMXAA8727E"}},"reasonCode":"BMXAA8727E","message":"The OSLC resource MXAPIAPIKEY with the ID _WmxvZlZLNVl2V3dGa1FseUJoKzJ4ZzQzSEd1bmRUamdWcTFiV1hWMGQ5QnAyNHQxQm53TmVFRWtVbmN4YkI2alZSTlp3eElsQko2bElNSCJzcCJ1M3hiNlE9PQ-- was not found as it does not exist in the system. In the database, verify whether the resource for the ID exists.","statusCode":"404"}}
618+
raise Exception(f"{response.status_code} {response.text}")
620619

621620
def get_manage_group_id(self, group_name, manage_api_key):
622621
self.logger.debug(f"Getting ID for Manage group {group_name}")

test/src/test_users.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,8 +1047,22 @@ def test_create_or_get_manage_api_key_for_user_error(user_utils, requests_mock,
10471047

10481048

10491049
def test_delete_manage_api_key(user_utils, requests_mock):
1050-
pass
1051-
# TODO
1050+
user_id = "user1"
1051+
apikey_id = "theapikeyid"
1052+
apikey = {"userid": user_id, "href": f"https://{MANAGE_API_URL}:{MANAGE_API_PORT}/maximo/api/os/mxapiapikey/{apikey_id}"}
1053+
1054+
delete = requests_mock.delete(
1055+
f"{MANAGE_API_URL}/maximo/api/os/mxapiapikey/{apikey_id}?ccm=1&lean=1",
1056+
request_headers={"accept": "application/json"},
1057+
text="notused",
1058+
status_code=204,
1059+
additional_matcher=lambda req: additional_matcher(req, cert=PEM_PATH)
1060+
)
1061+
1062+
user_utils.delete_manage_api_key(apikey)
1063+
assert delete.call_count == 1
1064+
1065+
# TODO: href_does_not_parse
10521066

10531067

10541068
def test_get_manage_group_id(user_utils, requests_mock):

0 commit comments

Comments
 (0)