passing test

This commit is contained in:
Pablo Martin 2024-06-06 12:56:36 +02:00
parent fc832df956
commit e5a2fbd002

View file

@ -1,7 +1,36 @@
import logging
import os
from xecd_rates_client import XecdClient
logger = logging.getLogger()
def run_xe_healthcheck():
logger.info("Checking checking")
logger.info("Creating client.")
xecd = XecdClient(
account_id=os.environ["XE_ACCOUNT_ID"],
api_key=os.environ["XE_API_KEY"],
)
logger.info("Requesting account info.")
try:
account_info_response = xecd.account_info()
except Exception as e:
logger.error(
"There was an exception when trying to reach xe.com. See details below."
)
logger.error(e)
raise e
contains_good_response_fields = bool(
("id" in account_info_response.keys())
and ("organization" in account_info_response.keys())
and ("package" in account_info_response.keys()),
)
if not contains_good_response_fields:
raise ConnectionError("Response from xe.com is not successful.")
logger.info("xe.com reached successfully.")
logger.info("See response below.")
logger.info(account_info_response)