full coverage
This commit is contained in:
parent
f2756506af
commit
661a1a98da
@ -135,3 +135,22 @@ class ScrapeTestCase(IsolatedAsyncioTestCase):
|
||||
])
|
||||
mock_trs_from_page.assert_has_calls([call(mock_soup), call(mock_soup)])
|
||||
mock_extract_row_data.assert_called_once_with(*mock_trs)
|
||||
|
||||
@patch.object(scrape, 'get_data_from_category')
|
||||
@patch.object(scrape, 'ClientSession')
|
||||
async def test_get_all_data(self, mock_session_cls, mock_get_data_from_category):
|
||||
mock_session = MagicMock()
|
||||
mock_session_cls.return_value.__aenter__.return_value = mock_session
|
||||
mock_result = ['foo']
|
||||
expected_output = len(scrape.CATEGORIES) * mock_result
|
||||
mock_get_data_from_category.return_value = mock_result
|
||||
output = await scrape.get_all_data(sequential=True)
|
||||
self.assertListEqual(expected_output, output)
|
||||
mock_get_data_from_category.assert_has_calls([
|
||||
call(category, mock_session) for category in scrape.CATEGORIES
|
||||
])
|
||||
output = await scrape.get_all_data(sequential=False)
|
||||
self.assertListEqual(expected_output, output)
|
||||
mock_get_data_from_category.assert_has_calls([
|
||||
call(category, mock_session) for category in scrape.CATEGORIES
|
||||
])
|
||||
|
Loading…
Reference in New Issue
Block a user