function for checking tr relevance
This commit is contained in:
@ -44,17 +44,21 @@ class FunctionsTestCase(IsolatedAsyncioTestCase):
|
||||
output = functions.extract_end_dates(self.test_soup)
|
||||
self.assertTupleEqual(expected_output, output)
|
||||
|
||||
def test_find_relevant_table_rows(self):
|
||||
test_table = self.test_soup.find('div', attrs={'class': 'financials'}).div.div.table
|
||||
expected_output = [test_table.thead.tr, test_table.tbody.tr]
|
||||
# print(expected_output) # debug
|
||||
def test_is_relevant_table_row(self):
|
||||
test_html = '<tr><td><div> Cash & Short Term Investments </div></td></tr>'
|
||||
test_soup = BeautifulSoup(test_html, functions.HTML_PARSER)
|
||||
self.assertTrue(functions.is_relevant_table_row(test_soup.tr))
|
||||
test_html = '<tr><td><div> Cash & Short Term Investments Growth </div></td></tr>'
|
||||
test_soup = BeautifulSoup(test_html, functions.HTML_PARSER)
|
||||
self.assertFalse(functions.is_relevant_table_row(test_soup.tr))
|
||||
|
||||
@patch.object(functions, 'is_relevant_table_row')
|
||||
def test_find_relevant_table_rows(self, mock_is_relevant_table_row):
|
||||
mock_is_relevant_table_row.return_value = True
|
||||
expected_output = self.test_soup.find('div', attrs={'class': 'financials'}).div.div.table.tbody.find_all('tr')
|
||||
output = functions.find_relevant_table_rows(self.test_soup)
|
||||
self.assertListEqual(expected_output, output)
|
||||
|
||||
def test_convert_number(self):
|
||||
# likely not necessary if data-chart-data is used
|
||||
# e.g. floats may be converted on extraction
|
||||
pass
|
||||
mock_is_relevant_table_row.assert_has_calls([call(expected_output[0]), call(expected_output[1])])
|
||||
|
||||
def test_extract_row_data(self):
|
||||
test_table = self.test_soup.find('div', attrs={'class': 'financials'}).div.div.table
|
||||
|
Reference in New Issue
Block a user