Test Overview
This test sends a GET request to a REST API endpoint and verifies that the response status code is 200, indicating success.
This test sends a GET request to a REST API endpoint and verifies that the response status code is 200, indicating success.
import requests def test_get_api_status(): url = "https://jsonplaceholder.typicode.com/posts/1" response = requests.get(url) assert response.status_code == 200 data = response.json() assert data["id"] == 1
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test environment ready, no network calls made yet | - | PASS |
| 2 | Send GET request to https://jsonplaceholder.typicode.com/posts/1 | Request sent to the API server | - | PASS |
| 3 | Receive response from API | Response received with status code 200 and JSON body | Check if response.status_code == 200 | PASS |
| 4 | Parse JSON response body | Response body parsed into a dictionary | Check if data["id"] == 1 | PASS |
| 5 | Test ends successfully | All assertions passed, test completed | - | PASS |