+ self.assertEqual("", stdout_mock.getvalue())
+
+ main.process("config", 1, "report_path", args_mock)
+
+ market_mock.from_config.assert_has_calls([
+ mock.call("config", debug="debug", user_id=1, report_path="report_path"),
+ mock.call().process("action", before="before", after="after"),
+ ])
+
+ with self.subTest(exception=True):
+ market_mock.from_config.side_effect = Exception("boo")
+ main.process("config", 1, "report_path", args_mock)
+ self.assertEqual("Exception: boo\n", stdout_mock.getvalue())
+
+ def test_main(self):
+ 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("main.process") as process:
+
+ args_mock = mock.Mock()
+ args_mock.config = "config"
+ args_mock.user = "user"