planned function to get row indent

This commit is contained in:
Maximilian Fajnberg 2021-12-26 18:40:29 +01:00
parent f7cb5de928
commit 8afab2fde8

View File

@ -51,21 +51,36 @@ class FunctionsTestCase(IsolatedAsyncioTestCase):
output = await functions.soup_from_url('baz', mock_session_obj) output = await functions.soup_from_url('baz', mock_session_obj)
self.assertEqual(expected_output, output) self.assertEqual(expected_output, output)
def test_extract_end_dates(self): def test_get_row_indent(self):
expected_output = ('End_Date_1', 'End_Date_2') trs = self.test_soup.find_all('tr')
expected_output = 0
output = functions.get_row_indent(trs[0])
self.assertEqual(expected_output, output)
for i, tr in enumerate(trs[1:], start=1):
output = functions.get_row_indent(tr)
self.assertEqual(i, output)
@patch.object(functions, 'get_row_indent')
def test_extract_end_dates(self, mock_get_row_indent):
mock_get_row_indent.return_value = 0
expected_output = (0, 'End_Date_1', 'End_Date_2')
output = functions.extract_end_dates(self.test_soup) output = functions.extract_end_dates(self.test_soup)
self.assertTupleEqual(expected_output, output) self.assertTupleEqual(expected_output, output)
mock_get_row_indent.assert_called_once_with(self.test_soup.tr)
def test_get_all_table_rows(self): def test_get_all_table_rows(self):
expected_output = self.test_soup.find('div', attrs={'class': 'financials'}).tbody.find_all('tr') expected_output = self.test_soup.find('div', attrs={'class': 'financials'}).tbody.find_all('tr')
output = functions.get_all_table_rows(self.test_soup) output = functions.get_all_table_rows(self.test_soup)
self.assertSequenceEqual(expected_output, output) self.assertSequenceEqual(expected_output, output)
def test_extract_row_data(self): @patch.object(functions, 'get_row_indent')
def test_extract_row_data(self, mock_get_row_indent):
mock_get_row_indent.return_value = 1
test_row = self.test_soup.find('div', attrs={'class': 'financials'}).tbody.tr test_row = self.test_soup.find('div', attrs={'class': 'financials'}).tbody.tr
expected_output = ('foo', (1, 1., -2.)) expected_output = ('foo', (1, 1., -2.))
output = functions.extract_row_data(test_row) output = functions.extract_row_data(test_row)
self.assertTupleEqual(expected_output, output) self.assertTupleEqual(expected_output, output)
mock_get_row_indent.assert_called_once_with(test_row)
@patch.object(functions, 'extract_row_data') @patch.object(functions, 'extract_row_data')
@patch.object(functions, 'get_all_table_rows') @patch.object(functions, 'get_all_table_rows')