pytest-openapi 0.3.0__tar.gz → 0.3.1.dev202604100227__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytest_openapi-0.3.0/src/pytest_openapi.egg-info → pytest_openapi-0.3.1.dev202604100227}/PKG-INFO +1 -1
- pytest_openapi-0.3.1.dev202604100227/src/pytest_openapi/__init__.py +1 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/src/pytest_openapi/openapi.py +31 -12
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/src/pytest_openapi/plugin.py +23 -8
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227/src/pytest_openapi.egg-info}/PKG-INFO +1 -1
- pytest_openapi-0.3.0/src/pytest_openapi/__init__.py +0 -1
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/LICENSE +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/README.md +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/pyproject.toml +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/setup.cfg +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/src/pytest_openapi/case_generator.py +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/src/pytest_openapi/contract.py +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/src/pytest_openapi/schema.py +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/src/pytest_openapi.egg-info/SOURCES.txt +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/src/pytest_openapi.egg-info/dependency_links.txt +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/src/pytest_openapi.egg-info/entry_points.txt +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/src/pytest_openapi.egg-info/requires.txt +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/src/pytest_openapi.egg-info/top_level.txt +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/tests/test_integration.py +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/tests/test_output_formats.py +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/tests/test_plugin_behavior.py +0 -0
- {pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/tests/test_unit.py +0 -0
{pytest_openapi-0.3.0/src/pytest_openapi.egg-info → pytest_openapi-0.3.1.dev202604100227}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-openapi
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1.dev202604100227
|
|
4
4
|
Summary: `pytest --openapi` - an opinionated, lightweight black-box contract tester against a live API using its OpenAPI specification as the source of truth
|
|
5
5
|
Author-email: Sinan Ozel <coding@sinan.slmail.me>
|
|
6
6
|
License: MIT License
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.1.dev202604100227"
|
|
@@ -196,18 +196,37 @@ def validate_openapi_spec(base_url, timeout=10):
|
|
|
196
196
|
"""
|
|
197
197
|
openapi_url = f"{base_url}/openapi.json"
|
|
198
198
|
|
|
199
|
-
# Check 1: Fetch OpenAPI spec
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
199
|
+
# Check 1: Fetch OpenAPI spec (with up to 3 retries)
|
|
200
|
+
max_attempts = 4
|
|
201
|
+
last_error = None
|
|
202
|
+
spec = None
|
|
203
|
+
for attempt in range(1, max_attempts + 1):
|
|
204
|
+
try:
|
|
205
|
+
response = requests.get(openapi_url, timeout=timeout)
|
|
206
|
+
response.raise_for_status()
|
|
207
|
+
spec = response.json()
|
|
208
|
+
break
|
|
209
|
+
except requests.exceptions.RequestException as e:
|
|
210
|
+
last_error = e
|
|
211
|
+
if attempt < max_attempts:
|
|
212
|
+
print(
|
|
213
|
+
f"\n⚠️ Attempt {attempt}/{max_attempts} failed"
|
|
214
|
+
f" fetching {openapi_url}: {e}. Retrying..."
|
|
215
|
+
)
|
|
216
|
+
except ValueError as e:
|
|
217
|
+
last_error = e
|
|
218
|
+
break
|
|
219
|
+
if spec is None:
|
|
220
|
+
if isinstance(last_error, ValueError):
|
|
221
|
+
print(
|
|
222
|
+
f"\n❌ ERROR: Invalid JSON in OpenAPI spec from {openapi_url}"
|
|
223
|
+
)
|
|
224
|
+
else:
|
|
225
|
+
print(
|
|
226
|
+
f"\n❌ ERROR: Could not fetch OpenAPI spec from {openapi_url}"
|
|
227
|
+
f" after {max_attempts} attempts"
|
|
228
|
+
)
|
|
229
|
+
print(f" Reason: {last_error}")
|
|
211
230
|
sys.exit(1)
|
|
212
231
|
# TODO: Add JsonDecodeError handling
|
|
213
232
|
|
|
@@ -88,15 +88,30 @@ def pytest_configure(config):
|
|
|
88
88
|
# Run validation checks
|
|
89
89
|
validate_openapi_spec(base_url, timeout=openapi_timeout)
|
|
90
90
|
|
|
91
|
-
# Fetch the OpenAPI spec
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
# Fetch the OpenAPI spec (with up to 3 retries)
|
|
92
|
+
spec = None
|
|
93
|
+
last_exc = None
|
|
94
|
+
for attempt in range(1, 5):
|
|
95
|
+
try:
|
|
96
|
+
response = requests.get(
|
|
97
|
+
f"{base_url}/openapi.json", timeout=openapi_timeout
|
|
98
|
+
)
|
|
99
|
+
response.raise_for_status()
|
|
100
|
+
spec = response.json()
|
|
101
|
+
break
|
|
102
|
+
except (requests.exceptions.RequestException, ValueError) as e:
|
|
103
|
+
last_exc = e
|
|
104
|
+
if attempt < 4:
|
|
105
|
+
print(
|
|
106
|
+
f"\n⚠️ Attempt {attempt}/4 failed fetching"
|
|
107
|
+
f" OpenAPI spec: {e}. Retrying..."
|
|
108
|
+
)
|
|
109
|
+
if spec is None:
|
|
110
|
+
pytest.exit(
|
|
111
|
+
f"\n❌ Failed to fetch OpenAPI spec after 4 attempts:"
|
|
112
|
+
f" {last_exc}",
|
|
113
|
+
returncode=1,
|
|
95
114
|
)
|
|
96
|
-
response.raise_for_status()
|
|
97
|
-
spec = response.json()
|
|
98
|
-
except (requests.exceptions.RequestException, ValueError) as e:
|
|
99
|
-
pytest.exit(f"\n❌ Failed to fetch OpenAPI spec: {e}", returncode=1)
|
|
100
115
|
|
|
101
116
|
# Reset server state if /reset endpoint exists (for testing)
|
|
102
117
|
try:
|
{pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227/src/pytest_openapi.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-openapi
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1.dev202604100227
|
|
4
4
|
Summary: `pytest --openapi` - an opinionated, lightweight black-box contract tester against a live API using its OpenAPI specification as the source of truth
|
|
5
5
|
Author-email: Sinan Ozel <coding@sinan.slmail.me>
|
|
6
6
|
License: MIT License
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/src/pytest_openapi/case_generator.py
RENAMED
|
File without changes
|
{pytest_openapi-0.3.0 → pytest_openapi-0.3.1.dev202604100227}/src/pytest_openapi/contract.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|