Untitled

mail@pastecode.io avatar
unknown
python
a year ago
604 B
1
Indexable
Never
import requests
import json

def test_github_api(userid,response_to_compare):
    # Define the user ID and endpoint URL
    
    url = f"https://api.github.com/users/{userid}"

    # Send a GET request to the API endpoint
    response = requests.get(url)

    # Extract the JSON response body from the response object
    body = json.loads(response.text)

    # Check the data you need
    assert response.status_code == 200
    assert body["name"] == response_to_compare['name']         
    .....
    
    
userid = 1
response_to_compare = {
    'name':'Michael',
    'id':'1825798'
}
test_github_api()