From: Ismaƫl Bouya Date: Tue, 8 May 2018 19:00:50 +0000 (+0200) Subject: Merge branch 'dev' X-Git-Tag: v1.8.1 X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git;a=commitdiff_plain;h=d3fec88cb0d301120b137692900d96bf475d2745;hp=aa169ddfbcf0a5002d5da6d62a76477c3e33e72e Merge branch 'dev' --- diff --git a/market.py b/market.py index caa9513..9550b77 100644 --- a/market.py +++ b/market.py @@ -1,4 +1,4 @@ -from ccxt import ExchangeError, NotSupported, RequestTimeout, InvalidNonce +from ccxt import AuthenticationError, ExchangeError, NotSupported, RequestTimeout, InvalidNonce import ccxt_wrapper as ccxt import time import dbs @@ -88,6 +88,7 @@ class Market: def process(self, actions, before=False, after=False): try: + self.ccxt.check_required_credentials() for action in actions: if bool(before) is bool(after): self.processor.process(action, steps="all") @@ -95,6 +96,8 @@ class Market: self.processor.process(action, steps="before") elif after: self.processor.process(action, steps="after") + except AuthenticationError: + self.report.log_error("market_authentication", message="Impossible to authenticate to market") except Exception as e: import traceback self.report.log_error("market_process", exception=e, message=traceback.format_exc()) diff --git a/tests/test_market.py b/tests/test_market.py index 2c92655..c89025b 100644 --- a/tests/test_market.py +++ b/tests/test_market.py @@ -887,6 +887,17 @@ class MarketTest(WebMockTestCase): store_report.assert_called_once() log_error.assert_not_called() + process.reset_mock() + log_error.reset_mock() + store_report.reset_mock() + with self.subTest(authentication_error=True): + m.ccxt.check_required_credentials.side_effect = market.ccxt.AuthenticationError + + m.process(["some_action"], before=True) + log_error.assert_called_with("market_authentication", message="Impossible to authenticate to market") + store_report.assert_called_once() + + m.ccxt.check_required_credentials.side_effect = True process.reset_mock() log_error.reset_mock() store_report.reset_mock()