Adding tests

This commit is contained in:
Cameron Ruatta
2019-06-16 10:24:39 -07:00
parent 26c151dd3f
commit 93d9154bc9
2 changed files with 40 additions and 28 deletions
+25
View File
@@ -39,6 +39,31 @@ class TestSearchGithubCode:
test_result = test_class_instance.fragments_from_response(response)
assert test_result == ["test1", "test2"]
def test_fail_fragments_from_response(self):
Core.github_key = MagicMock(return_value="lol")
test_class_instance = githubcode.SearchGithubCode(word="test", limit=500)
response = Response()
json = {
"items": [
{
"fail": True
},
{
"text_matches": []
},
{
"text_matches": [
{
"weird": "result"
}
]
}
]
}
response.json = MagicMock(return_value=json)
test_result = test_class_instance.fragments_from_response(response)
assert test_result == []
if __name__ == '__main__':
pytest.main()