From 18de421e455ab4b125a6684d703a296562097e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 9 Apr 2018 11:52:45 +0200 Subject: Fix ccxt switching currency codes --- tests/test_ccxt_wrapper.py | 4 ++++ tests/test_portfolio.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'tests') diff --git a/tests/test_ccxt_wrapper.py b/tests/test_ccxt_wrapper.py index f07674e..18feab3 100644 --- a/tests/test_ccxt_wrapper.py +++ b/tests/test_ccxt_wrapper.py @@ -477,4 +477,8 @@ class poloniexETest(unittest.TestCase): create_order.assert_called_once_with("symbol", "type", "side", "amount", price="price", params="params") + def test_common_currency_code(self): + self.assertEqual("FOO", self.s.common_currency_code("FOO")) + def test_currency_id(self): + self.assertEqual("FOO", self.s.currency_id("FOO")) diff --git a/tests/test_portfolio.py b/tests/test_portfolio.py index 2a42d0c..14dc995 100644 --- a/tests/test_portfolio.py +++ b/tests/test_portfolio.py @@ -218,6 +218,26 @@ class TradeTest(WebMockTestCase): self.assertEqual(0, len(trade.orders)) Order.assert_not_called() + self.m.get_ticker.return_value = None + with self.subTest(desc="Unknown ticker"): + filled_amount.return_value = portfolio.Amount("BTC", "3") + compute_value.return_value = D("0.125") + + value_from = portfolio.Amount("BTC", "1") + value_from.rate = D("0.1") + value_from.linked_to = portfolio.Amount("FOO", "10") + value_to = portfolio.Amount("BTC", "10") + trade = portfolio.Trade(value_from, value_to, "FOO", self.m) + + trade.prepare_order() + + filled_amount.assert_not_called() + compute_value.assert_not_called() + self.assertEqual(0, len(trade.orders)) + Order.assert_not_called() + self.m.report.log_error.assert_called_once_with('prepare_order', + message='Unknown ticker FOO/BTC') + self.m.get_ticker.return_value = { "inverted": False } with self.subTest(desc="Already filled"): filled_amount.return_value = portfolio.Amount("FOO", "100") -- cgit v1.2.3