add a boat load of static typing fixes

This commit is contained in:
L1ghtn1ng
2022-10-31 00:51:59 +00:00
parent a081b3942d
commit f175269941
56 changed files with 286 additions and 253 deletions
+7 -6
View File
@@ -4,8 +4,9 @@ from theHarvester.lib.core import Core
from unittest.mock import MagicMock
from requests import Response
import pytest
from _pytest.mark.structures import MarkDecorator
pytestmark = pytest.mark.asyncio
pytestmark: MarkDecorator = pytest.mark.asyncio
class TestSearchGithubCode:
@@ -65,31 +66,31 @@ class TestSearchGithubCode:
response.json = MagicMock(return_value=json)
response.status_code = 200
async def test_missing_key(self):
async def test_missing_key(self) -> None:
with pytest.raises(MissingKey):
Core.github_key = MagicMock(return_value=None)
githubcode.SearchGithubCode(word="test", limit=500)
async def test_fragments_from_response(self):
async def test_fragments_from_response(self) -> None:
Core.github_key = MagicMock(return_value="lol")
test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
test_result = await test_class_instance.fragments_from_response(self.OkResponse.response.json())
print('test_result: ', test_result)
assert test_result == ["test1", "test2"]
async def test_invalid_fragments_from_response(self):
async def test_invalid_fragments_from_response(self) -> None:
Core.github_key = MagicMock(return_value="lol")
test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
test_result = await test_class_instance.fragments_from_response(self.MalformedResponse.response.json())
assert test_result == []
async def test_next_page(self):
async def test_next_page(self) -> None:
Core.github_key = MagicMock(return_value="lol")
test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
test_result = githubcode.SuccessResult(list(), next_page=2, last_page=4)
assert (2 == await test_class_instance.next_page_or_end(test_result))
async def test_last_page(self):
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)