diff --git a/tests/discovery/githubcode.py b/tests/discovery/githubcode.py index b8f358f9..da88196c 100644 --- a/tests/discovery/githubcode.py +++ b/tests/discovery/githubcode.py @@ -74,44 +74,45 @@ class TestSearchGithubCode: async def test_fragments_from_response(self): 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) + 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): Core.github_key = MagicMock(return_value="lol") test_class_instance = githubcode.SearchGithubCode(word="test", limit=500) - test_result = test_class_instance.fragments_from_response(self.MalformedResponse.response) + test_result = await test_class_instance.fragments_from_response(self.MalformedResponse.response.json()) assert test_result == [] async def test_handle_response_ok(self): Core.github_key = MagicMock(return_value="lol") test_class_instance = githubcode.SearchGithubCode(word="test", limit=500) - test_result = test_class_instance.handle_response(self.OkResponse.response) + test_result = await test_class_instance.handle_response() assert isinstance(test_result, SuccessResult) async def test_handle_response_retry(self): Core.github_key = MagicMock(return_value="lol") test_class_instance = githubcode.SearchGithubCode(word="test", limit=500) - test_result = test_class_instance.handle_response(self.RetryResponse.response) + test_result = await test_class_instance.handle_response(self.RetryResponse.response.json()) assert isinstance(test_result, RetryResult) async def test_handle_response_fail(self): Core.github_key = MagicMock(return_value="lol") test_class_instance = githubcode.SearchGithubCode(word="test", limit=500) - test_result = test_class_instance.handle_response(self.FailureResponse.response) + test_result = await test_class_instance.handle_response(self.FailureResponse.response.json()) assert isinstance(test_result, ErrorResult) async def test_next_page(self): 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 == test_class_instance.next_page_or_end(test_result)) + assert(2 == await test_class_instance.next_page_or_end(test_result)) async def test_last_page(self): 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 test_class_instance.next_page_or_end(test_result)) + assert(None is await test_class_instance.next_page_or_end(test_result)) if __name__ == '__main__': pytest.main() diff --git a/theHarvester/discovery/githubcode.py b/theHarvester/discovery/githubcode.py index b9d3383c..f081b452 100644 --- a/theHarvester/discovery/githubcode.py +++ b/theHarvester/discovery/githubcode.py @@ -95,7 +95,7 @@ class SearchGithubCode: async with sess.get(url, proxy=random.choice(Core.proxy_list())) as resp: return await resp.text(), await resp.json(), resp.status, resp.links else: - async with sess.get(url, ) as resp: + async with sess.get(url) as resp: return await resp.text(), await resp.json(), resp.status, resp.links @staticmethod