From e7f3730c646787569c6bc137170f79688496a85f Mon Sep 17 00:00:00 2001 From: Daniil Fajnberg Date: Sun, 28 Nov 2021 16:39:53 +0100 Subject: [PATCH] idea for getting financials for an arbitrary number of companies --- tests/test_functions.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/test_functions.py b/tests/test_functions.py index cf84aa8..cad26ea 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -160,11 +160,32 @@ class FunctionsTestCase(IsolatedAsyncioTestCase): CF: {END_DATE: mock_end_dates, 'c': (3, 4)} } symbol, quarterly, mock_session = 'foo', False, MagicMock() - output = await functions.get_company_financials(symbol, quarterly, mock_session) + output = await functions.get_company_financials(symbol, quarterly=quarterly, session=mock_session) self.assertDictEqual(expected_output, output) mock_get_bs.assert_called_once_with(symbol, quarterly, mock_session) mock_get_is.assert_called_once_with(symbol, quarterly, mock_session) mock_get_cf.assert_called_once_with(symbol, quarterly, mock_session) + mock_get_bs.reset_mock() + mock_get_is.reset_mock() + mock_get_cf.reset_mock() + + test_symbol1, test_symbol2 = 'x', 'y' + expected_output = {test_symbol1: expected_output, test_symbol2: expected_output} + output = await functions.get_company_financials(test_symbol1, test_symbol2, + quarterly=quarterly, session=mock_session) + self.assertDictEqual(expected_output, output) + mock_get_bs.assert_has_calls([ + call(test_symbol1, quarterly, mock_session), + call(test_symbol2, quarterly, mock_session) + ]) + mock_get_is.assert_has_calls([ + call(test_symbol1, quarterly, mock_session), + call(test_symbol2, quarterly, mock_session) + ]) + mock_get_cf.assert_has_calls([ + call(test_symbol1, quarterly, mock_session), + call(test_symbol2, quarterly, mock_session) + ]) @patch.object(functions, 'ClientSession') async def test_integration_get_company_financials(self, mock_session_cls):