From 8041386d52dafe03b07d547ac7779f413016976a Mon Sep 17 00:00:00 2001 From: Maximilian Fajnberg Date: Wed, 24 Nov 2021 15:28:34 +0100 Subject: [PATCH] more unit tests --- tests/test_functions.py | 18 +++++++++++++--- tests/test_structure.html | 44 +++++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/tests/test_functions.py b/tests/test_functions.py index 348575f..3560138 100644 --- a/tests/test_functions.py +++ b/tests/test_functions.py @@ -45,16 +45,28 @@ class FunctionsTestCase(IsolatedAsyncioTestCase): self.assertTupleEqual(expected_output, output) def test_find_relevant_table_rows(self): - pass + 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 + 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 def test_extract_row_data(self): - pass + test_table = self.test_soup.find('div', attrs={'class': 'financials'}).div.div.table + expected_output = ('Item_1', (11000000.0, -22000000.0)) + output = functions.extract_row_data(test_table.tbody.tr) + # print(test_table.tbody.tr) # debug + self.assertTupleEqual(expected_output, output) def test_extract_all_data(self): - pass + expected_output = {'Item_1': (11000000.0, -22000000.0)} + output = functions.extract_row_data(self.test_soup) + self.assertDictEqual(expected_output, output) async def test_get_balance_sheet(self): pass diff --git a/tests/test_structure.html b/tests/test_structure.html index 7f2d47a..b0b7ce5 100644 --- a/tests/test_structure.html +++ b/tests/test_structure.html @@ -13,28 +13,28 @@
- - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + +
'Item'
'Item'
End_Date_1
End_Date_2
Item_1
Item_1
Item_2
Item_2
!!Item
!!Item
End_Date_1
End_Date_2
Item_1
Item_1
Item_2
Item_2