mirror of
https://github.com/laramies/theHarvester.git
synced 2025-02-23 05:52:59 +08:00
Add async pagination helper and update pytest settings
Introduce the `next_page_or_end` method in `githubcode.py` to handle pagination. Additionally, modify the test case and upgrade pytest settings in `pyproject.toml` to the latest versions, ensuring compatibility and updated configurations.
This commit is contained in:
parent
c18012d50a
commit
13a0cdd62a
3 changed files with 12 additions and 4 deletions
|
@ -35,8 +35,10 @@ include = ["theHarvester*"]
|
|||
"*" = ["*.txt", "*.yaml"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
minversion = "7.1.1"
|
||||
addopts = "--no-header --asyncio-mode=auto"
|
||||
minversion = "8.3.3"
|
||||
asyncio_mode = "auto"
|
||||
asyncio_default_fixture_loop_scope = "function"
|
||||
addopts = "--no-header"
|
||||
testpaths = [
|
||||
"tests",
|
||||
"tests/discovery/",
|
||||
|
|
|
@ -77,7 +77,6 @@ async def test_last_page(self) -> None:
|
|||
Core.github_key = MagicMock(return_value="lol")
|
||||
test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
|
||||
test_result = githubcode.SuccessResult(list(), None, None)
|
||||
assert None is await test_class_instance.next_page_or_end(test_result)
|
||||
|
||||
assert await test_class_instance.next_page_or_end(test_result) is None
|
||||
if __name__ == "__main__":
|
||||
pytest.main()
|
||||
|
|
|
@ -89,6 +89,13 @@ async def handle_response(self, response: tuple[str, dict, int, Any]) -> ErrorRe
|
|||
print(f'Error handling response: {e}')
|
||||
return ErrorResult(500, str(e))
|
||||
|
||||
@staticmethod
|
||||
async def next_page_or_end(result: SuccessResult) -> int | None:
|
||||
if result.next_page is not None:
|
||||
return result.next_page
|
||||
else:
|
||||
return result.last_page
|
||||
|
||||
async def do_search(self, page: int) -> tuple[str, dict, int, Any]:
|
||||
try:
|
||||
url = f'{self.base_url}&page={page}' if page else self.base_url
|
||||
|
|
Loading…
Reference in a new issue