concurrency for getting all three financial statements; improved imports; renamed functions
This commit is contained in:
@ -171,11 +171,11 @@ class FunctionsTestCase(IsolatedAsyncioTestCase):
|
||||
await self._helper_test_get_any_statement(CF, mock__get_multi_companies_fin_stmt)
|
||||
|
||||
@patch.object(functions, '_get_single_company_fin_stmt')
|
||||
async def test__get_single_company_financials(self, mock__get_single_company_fin_stmt):
|
||||
async def test__get_single_company_all_financials(self, mock__get_single_company_fin_stmt):
|
||||
symbol, quarterly, mock_session = 'foo', False, MagicMock()
|
||||
mock__get_single_company_fin_stmt.return_value = bar = 'bar'
|
||||
expected_output = {BS: bar, IS: bar, CF: bar}
|
||||
output = await functions._get_single_company_financials(symbol, quarterly, mock_session)
|
||||
output = await functions._get_single_company_all_financials(symbol, quarterly, mock_session)
|
||||
self.assertDictEqual(expected_output, output)
|
||||
mock__get_single_company_fin_stmt.assert_has_calls([
|
||||
call(BS, symbol, quarterly, mock_session),
|
||||
@ -183,21 +183,21 @@ class FunctionsTestCase(IsolatedAsyncioTestCase):
|
||||
call(CF, symbol, quarterly, mock_session)
|
||||
])
|
||||
|
||||
@patch.object(functions, '_get_single_company_financials')
|
||||
async def test_get_company_financials(self, mock__get_single_company_financials):
|
||||
mock__get_single_company_financials.return_value = expected_output = 'baz'
|
||||
@patch.object(functions, '_get_single_company_all_financials')
|
||||
async def test_get_company_financials(self, mock__get_single_company_all_financials):
|
||||
mock__get_single_company_all_financials.return_value = expected_output = 'baz'
|
||||
symbol, quarterly, mock_session = 'foo', False, MagicMock()
|
||||
output = await functions.get_company_financials(symbol, quarterly=quarterly, session=mock_session)
|
||||
output = await functions.get_all_financials(symbol, quarterly=quarterly, session=mock_session)
|
||||
self.assertEqual(expected_output, output)
|
||||
mock__get_single_company_financials.assert_called_once_with(symbol, quarterly, mock_session)
|
||||
mock__get_single_company_financials.reset_mock()
|
||||
mock__get_single_company_all_financials.assert_called_once_with(symbol, quarterly, mock_session)
|
||||
mock__get_single_company_all_financials.reset_mock()
|
||||
|
||||
test_sym1, test_sym2 = 'x', 'y'
|
||||
expected_output = {test_sym1: expected_output, test_sym2: expected_output}
|
||||
output = await functions.get_company_financials(test_sym1, test_sym2,
|
||||
quarterly=quarterly, session=mock_session)
|
||||
output = await functions.get_all_financials(test_sym1, test_sym2,
|
||||
quarterly=quarterly, session=mock_session)
|
||||
self.assertDictEqual(expected_output, output)
|
||||
mock__get_single_company_financials.assert_has_calls([
|
||||
mock__get_single_company_all_financials.assert_has_calls([
|
||||
call(test_sym1, quarterly, mock_session),
|
||||
call(test_sym2, quarterly, mock_session)
|
||||
])
|
||||
@ -212,7 +212,7 @@ class FunctionsTestCase(IsolatedAsyncioTestCase):
|
||||
IS: {END_DATE: ('End_Date_1', 'End_Date_2'), 'Cash & Short Term Investments': (11000000, -22000000)},
|
||||
CF: {END_DATE: ('End_Date_1', 'End_Date_2'), 'Cash & Short Term Investments': (11000000, -22000000)}
|
||||
}
|
||||
output = await functions.get_company_financials(symbol, session=mock_session_obj)
|
||||
output = await functions.get_all_financials(symbol, session=mock_session_obj)
|
||||
self.assertDictEqual(expected_output, output)
|
||||
mock_session_obj.get.assert_has_calls([
|
||||
call(f'{BASE_URL}/{symbol}/financials{FIN_STMT_URL_SUFFIX[BS]}'),
|
||||
|
Reference in New Issue
Block a user