コード例 #1
0
def get_github_user_from_github(email):
    result = search(email)
    if not result.get('total_count', 0):
        # print(result)
        raise Exception("no users found")

    return result['items'][0]
コード例 #2
0
    def test_search(self):
        """Test the github utility search method."""
        url = 'https://api.github.com/search/users'
        responses.add(responses.GET,
                      url,
                      json={'total_count': '0'},
                      status=200)
        query = 'a-non-existent-test-string'
        params = {'q': query, 'sort': 'updated'}
        result = search(query)
        params = urlencode(params, quote_via=quote_plus)

        assert result == {'total_count': '0'}
        assert responses.calls[0].request.url == url + '?' + params
        assert responses.calls[0].response.text == '{"total_count": "0"}'