示例#1
0
 def test_get_first_search_result_invalid(self):
     fake_json = json.dumps({'items': []})
     url = "https://api.github.com/search/repositories?q=aksejake"
     with requests_mock.mock() as mocker:
         mocker.get(url, json=fake_json)
         response = json.loads(requests.get(url).json())
     with pytest.raises(Exception) as exc_info:
         gitdl.get_first_search_result(response)
     assert str(exc_info.value) == "Repository Not Found."
示例#2
0
 def test_get_first_search_result_valid(self):
     fake_json = json.dumps({'items': [{"id": 1, "name": "gitdl"}]})
     url = "https://api.github.com/search/repositories?q=aksejake"
     with requests_mock.mock() as mocker:
         mocker.get(url, json=fake_json)
         response = json.loads(requests.get(url).json())
     res = gitdl.get_first_search_result(response)
     self.assertEqual(res, {'id': 1, 'name': 'gitdl'})
示例#3
0
 def test_get_first_search_result_invalid(self):
     url = "https://api.github.com/search/repositories?q=aksejake"
     response = requests.get(url).json()
     with pytest.raises(Exception) as exc_info:
         gitdl.get_first_search_result(response)
     assert str(exc_info.value) == "Repository Not Found."