X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git;a=blobdiff_plain;f=tests%2Ftest_main.py;h=cee89ce6cb35d638914824ca12e85f236aee677f;hp=06fc84ef5e4492e4d98a905dd42675b56c2aacba;hb=a0dcf4e0978331709da164fb0e29ae008b90fc88;hpb=c8df27385e02b22d36b240fe29532e97dbba1f43 diff --git a/tests/test_main.py b/tests/test_main.py index 06fc84e..cee89ce 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -205,6 +205,48 @@ class MainTest(WebMockTestCase): mock.call.__bool__(), mock.call("config2", 1, 2, args_mock, "pg_config"), ]) + with self.subTest(quiet=True): + with mock.patch("main.parse_args") as parse_args,\ + mock.patch("main.parse_config") as parse_config,\ + mock.patch("main.fetch_markets") as fetch_markets,\ + mock.patch("store.Portfolio.report") as report,\ + mock.patch("main.process") as process: + + args_mock = mock.Mock() + args_mock.parallel = False + args_mock.quiet = True + args_mock.user = "user" + parse_args.return_value = args_mock + + parse_config.return_value = "pg_config" + + fetch_markets.return_value = [[3, "config1", 1], [1, "config2", 2]] + + main.main(["Foo", "Bar"]) + + report.set_verbose.assert_called_once_with(False) + + with self.subTest(quiet=False): + with mock.patch("main.parse_args") as parse_args,\ + mock.patch("main.parse_config") as parse_config,\ + mock.patch("main.fetch_markets") as fetch_markets,\ + mock.patch("store.Portfolio.report") as report,\ + mock.patch("main.process") as process: + + args_mock = mock.Mock() + args_mock.parallel = False + args_mock.quiet = False + args_mock.user = "user" + parse_args.return_value = args_mock + + parse_config.return_value = "pg_config" + + fetch_markets.return_value = [[3, "config1", 1], [1, "config2", 2]] + + main.main(["Foo", "Bar"]) + + report.set_verbose.assert_called_once_with(True) + @mock.patch.object(main.sys, "exit") @mock.patch("main.os")