company financials returned as separate dicts; test fix
This commit is contained in:
@ -74,7 +74,7 @@ class FunctionsTestCase(IsolatedAsyncioTestCase):
|
||||
|
||||
def test_extract_row_data(self):
|
||||
test_row = self.test_soup.find('div', attrs={'class': 'financials'}).tbody.tr
|
||||
expected_output = ('Item_1', (11000000, -22000000))
|
||||
expected_output = ('Cash & Short Term Investments', (11000000, -22000000))
|
||||
output = functions.extract_row_data(test_row)
|
||||
self.assertTupleEqual(expected_output, output)
|
||||
|
||||
@ -155,10 +155,9 @@ class FunctionsTestCase(IsolatedAsyncioTestCase):
|
||||
mock_get_is.return_value = {END_DATE: mock_end_dates, 'b': (2, 3)}
|
||||
mock_get_cf.return_value = {END_DATE: mock_end_dates, 'c': (3, 4)}
|
||||
expected_output = {
|
||||
END_DATE: mock_end_dates,
|
||||
'a': (1, 2),
|
||||
'b': (2, 3),
|
||||
'c': (3, 4)
|
||||
BS: {END_DATE: mock_end_dates, 'a': (1, 2)},
|
||||
IS: {END_DATE: mock_end_dates, 'b': (2, 3)},
|
||||
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)
|
||||
@ -171,12 +170,11 @@ class FunctionsTestCase(IsolatedAsyncioTestCase):
|
||||
async def test_integration_get_company_financials(self, mock_session_cls):
|
||||
mock_session_cls.return_value = mock_session_obj = self.get_mock_session(self.test_html)
|
||||
symbol = 'foo'
|
||||
# Since we mock the web request and always receive the same HTML markup,
|
||||
# and the function essentially does 3 separate requests always updating the output dictionary with the same
|
||||
# data, we expect it to remain unchanged and only having one item.
|
||||
# Since the web request is mocked we always receive the same HTML markup.
|
||||
expected_output = {
|
||||
END_DATE: ('End_Date_1', 'End_Date_2'),
|
||||
'Cash & Short Term Investments': (11000000, -22000000),
|
||||
BS: {END_DATE: ('End_Date_1', 'End_Date_2'), 'Cash & Short Term Investments': (11000000, -22000000)},
|
||||
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)
|
||||
self.assertDictEqual(expected_output, output)
|
||||
|
Reference in New Issue
Block a user