Add checkpoint logic and tests
This commit is contained in:
@@ -11,6 +11,7 @@ class _FakePage:
|
||||
def __init__(self, counts: dict[str, int]) -> None:
|
||||
self._counts = counts
|
||||
self._evaluate_result = False
|
||||
self._evaluate_values: list[object] = []
|
||||
|
||||
class _Locator:
|
||||
def __init__(self, count_value: int) -> None:
|
||||
@@ -23,6 +24,8 @@ class _FakePage:
|
||||
return _FakePage._Locator(self._counts.get(selector, 0))
|
||||
|
||||
def evaluate(self, _script: str):
|
||||
if self._evaluate_values:
|
||||
return self._evaluate_values.pop(0)
|
||||
return self._evaluate_result
|
||||
|
||||
|
||||
@@ -40,6 +43,11 @@ class TestListingUnit(unittest.TestCase):
|
||||
page._evaluate_result = True
|
||||
self.assertTrue(ListingCollector._has_next_page(page))
|
||||
|
||||
def test_get_current_page_number_from_text_counter(self) -> None:
|
||||
page = _FakePage({})
|
||||
page._evaluate_values = [5]
|
||||
self.assertEqual(ListingCollector._get_current_page_number(page), 5)
|
||||
|
||||
def test_extract_vehicle_links_from_html_finds_detail_urls(self) -> None:
|
||||
collector = ListingCollector(Settings(), HumanPacer(Settings()))
|
||||
html = """
|
||||
|
||||
Reference in New Issue
Block a user