From 4b598ca6f91236c94da250282ac8c89c7d947ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 25 Jul 2018 20:29:08 +0200 Subject: Some fixes - DB cursor expects an enumerable - None should be returned when repartition is not available --- tests/test_main.py | 2 +- tests/test_store.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_main.py b/tests/test_main.py index 298e29e..0b4745f 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -333,7 +333,7 @@ class MainTest(WebMockTestCase): with self.subTest(user=1): rows = list(main.fetch_markets(1)) - cursor_mock.execute.assert_called_once_with("SELECT id,config,user_id FROM market_configs WHERE status='enabled' AND user_id = %s", 1) + cursor_mock.execute.assert_called_once_with("SELECT id,config,user_id FROM market_configs WHERE status='enabled' AND user_id = %s", [1]) self.assertEqual(["row_1", "row_2"], rows) diff --git a/tests/test_store.py b/tests/test_store.py index 1a722b5..3097f6d 100644 --- a/tests/test_store.py +++ b/tests/test_store.py @@ -1537,6 +1537,18 @@ class PortfolioTest(WebMockTestCase): get_cryptoportfolio.assert_called_once_with() retrieve_cryptoportfolio.assert_called_once_with() + retrieve_cryptoportfolio.reset_mock() + get_cryptoportfolio.reset_mock() + + with self.subTest("absent liquidities"): + market.Portfolio.last_date = store.LockedVar("2018-03-15") + self.assertIsNone(market.Portfolio.repartition()) + + with self.subTest("no liquidities"): + market.Portfolio.liquidities = store.LockedVar({}) + market.Portfolio.last_date = store.LockedVar("2018-03-08") + self.assertIsNone(market.Portfolio.repartition()) + @mock.patch.object(market.time, "sleep") @mock.patch.object(market.Portfolio, "get_cryptoportfolio") def test_wait_for_recent(self, get_cryptoportfolio, sleep): -- cgit v1.2.3