mirror of
https://github.com/laramies/theHarvester.git
synced 2026-09-06 09:47:40 +02:00
More wip for getting tests working
This commit is contained in:
@@ -64,48 +64,56 @@ class TestSearchGithubCode:
|
||||
response.json = MagicMock(return_value=json)
|
||||
response.status_code = 200
|
||||
|
||||
def test_missing_key(self):
|
||||
@pytest.mark.asyncio
|
||||
async def test_missing_key(self):
|
||||
with pytest.raises(MissingKey):
|
||||
Core.github_key = MagicMock(return_value=None)
|
||||
githubcode.SearchGithubCode(word="test", limit=500)
|
||||
|
||||
def test_fragments_from_response(self):
|
||||
@pytest.mark.asyncio
|
||||
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 = test_class_instance.fragments_from_response(self.OkResponse.response)
|
||||
assert test_result == ["test1", "test2"]
|
||||
|
||||
def test_invalid_fragments_from_response(self):
|
||||
@pytest.mark.asyncio
|
||||
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)
|
||||
assert test_result == []
|
||||
|
||||
def test_handle_response_ok(self):
|
||||
@pytest.mark.asyncio
|
||||
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)
|
||||
assert isinstance(test_result, SuccessResult)
|
||||
|
||||
def test_handle_response_retry(self):
|
||||
@pytest.mark.asyncio
|
||||
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)
|
||||
assert isinstance(test_result, RetryResult)
|
||||
|
||||
def test_handle_response_fail(self):
|
||||
@pytest.mark.asyncio
|
||||
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)
|
||||
assert isinstance(test_result, ErrorResult)
|
||||
|
||||
def test_next_page(self):
|
||||
@pytest.mark.asyncio
|
||||
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))
|
||||
|
||||
def test_last_page(self):
|
||||
@pytest.mark.asyncio
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user