Compare commits

..

No commits in common. "04a87c1da672f4cfc9d7021728612ebdbd531d6b" and "74c46f2647fe133a933863b7395d027fe26aa37e" have entirely different histories.

View File

@ -4,13 +4,6 @@ from pydantic import ValidationError
from core.lib import schemas
from core.util import logs
# Return error if the schema for the message type is not found
STRICT_VALIDATION = False
# Raise exception if the conversion schema is not found
STRICT_CONVERSTION = False
# TODO: Set them to True when all message types are implemented
class BaseExchange(object):
def __init__(self, account):
@ -41,8 +34,7 @@ class BaseExchange(object):
else:
# Let us know so we can implement it, but don't do anything with it
self.log.error(f"No schema for message: {msg_type} - {response}")
if STRICT_CONVERSION:
raise Exception(f"No schema for {msg_type} in schema mapping")
# raise Exception(f"No schema for {msg_type} in schema mapping")
return response
# Use glom to convert the response to the schema
@ -60,8 +52,7 @@ class BaseExchange(object):
if method not in self.schema:
self.log.error(f"Method cannot be validated: {method}")
self.log.debug(f"Response: {response}")
if STRICT_VALIDATION:
return (False, f"Method cannot be validated: {method}")
# return (False, f"Method cannot be validated: {method}")
return (True, response)
# Return a dict of the validated response
response_valid = self.schema[method](**response).dict()