From: Ismaël Bouya Date: Wed, 26 Sep 2018 09:51:14 +0000 (+0200) Subject: Don’t raise when some market is disabled X-Git-Tag: v1.10.2^2 X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git;a=commitdiff_plain;h=512972fa1df14df4e208a1182096b1c51b5d38d1;hp=6746607a578eca3383ade7fe7a88c39612f4d6e8 Don’t raise when some market is disabled --- diff --git a/portfolio.py b/portfolio.py index 94472a3..1d29106 100644 --- a/portfolio.py +++ b/portfolio.py @@ -52,7 +52,7 @@ class Amount: ticker=asset_ticker, rate=rate) else: - raise Exception("This asset is not available in the chosen market") + return Amount(other_currency, 0, linked_to=self, ticker=None, rate=0) def as_json(self): return { diff --git a/tests/test_portfolio.py b/tests/test_portfolio.py index d4e5ab9..cad3095 100644 --- a/tests/test_portfolio.py +++ b/tests/test_portfolio.py @@ -1856,7 +1856,7 @@ class AmountTest(WebMockTestCase): with self.subTest(desc="no ticker for currency"): self.m.get_ticker.return_value = None - self.assertRaises(Exception, amount.in_currency, "ETH", self.m) + self.assertEqual(portfolio.Amount("ETH", 0), amount.in_currency("ETH", self.m)) with self.subTest(desc="nominal case"): self.m.get_ticker.return_value = {