Test Overview
This test checks if the Postman documentation for an API collection can be published successfully. It verifies that the documentation page loads and shows the expected title.
This test checks if the Postman documentation for an API collection can be published successfully. It verifies that the documentation page loads and shows the expected title.
import requests # Define the Postman API endpoint for publishing documentation url = "https://api.getpostman.com/documentation/publish" # API key for authentication (replace with valid key) headers = {"X-Api-Key": "{{API_KEY}}"} # Payload with collection UID and environment payload = { "collectionUid": "{{COLLECTION_UID}}", "environmentUid": "{{ENVIRONMENT_UID}}" } # Send POST request to publish documentation response = requests.post(url, headers=headers, json=payload) # Assert the response status code is 200 (success) assert response.status_code == 200, f"Expected status 200 but got {response.status_code}" # Assert the response contains published documentation URL data = response.json() assert "documentationUrl" in data, "Documentation URL not found in response" # Optionally, verify the documentation page loads import webbrowser webbrowser.open(data["documentationUrl"])
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Send POST request to Postman API to publish documentation with collection and environment UIDs | Request sent to https://api.getpostman.com/documentation/publish with valid headers and payload | Check response status code is 200 | PASS |
| 2 | Parse JSON response to check for documentationUrl field | Response JSON received with documentationUrl key | Verify documentationUrl key exists in response JSON | PASS |
| 3 | Open the documentation URL in default web browser | Browser opens with the published documentation page loaded | Visual check that documentation page title matches expected API collection name | PASS |