refactor and docstring

This commit is contained in:
Pablo Martin 2024-06-06 12:58:15 +02:00
parent e5a2fbd002
commit 464349be09

View file

@ -6,7 +6,14 @@ from xecd_rates_client import XecdClient
logger = logging.getLogger()
def run_xe_healthcheck():
def run_xe_healthcheck() -> None:
"""
Try to request the account data in xe.com's API.
If certain fields about the account are returned, it means the request was
successful.
"""
logger.info("Creating client.")
xecd = XecdClient(
account_id=os.environ["XE_ACCOUNT_ID"],
@ -29,6 +36,7 @@ def run_xe_healthcheck():
and ("package" in account_info_response.keys()),
)
if not contains_good_response_fields:
logger.error("Didn't find the fields of a good response.")
raise ConnectionError("Response from xe.com is not successful.")
logger.info("xe.com reached successfully.")