passing test
This commit is contained in:
parent
fc832df956
commit
e5a2fbd002
1 changed files with 30 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue