standardize packaging, tooling, docs, CI, and licensing
This commit is contained in:
43
tests/conftest.py
Normal file
43
tests/conftest.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""Shared fixtures for the openapi-first smoke test suite."""
|
||||
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
MINIMAL_SPEC = {
|
||||
"openapi": "3.0.3",
|
||||
"info": {"title": "Smoke Test API", "version": "1.0.0"},
|
||||
"servers": [{"url": "https://api.example.com/v1"}],
|
||||
"paths": {
|
||||
"/health": {
|
||||
"get": {
|
||||
"operationId": "get_health",
|
||||
"responses": {"200": {"description": "OK"}},
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def minimal_spec() -> dict:
|
||||
"""Return a minimal valid OpenAPI 3.0.3 specification."""
|
||||
return json.loads(json.dumps(MINIMAL_SPEC))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def spec_file(tmp_path, minimal_spec):
|
||||
"""Write the minimal spec to a temp JSON file and return its path."""
|
||||
|
||||
def _write(name: str, spec: dict | None = None) -> str:
|
||||
path = tmp_path / name
|
||||
payload = spec if spec is not None else minimal_spec
|
||||
if name.endswith(".json"):
|
||||
path.write_text(json.dumps(payload), encoding="utf-8")
|
||||
else:
|
||||
import yaml
|
||||
|
||||
path.write_text(yaml.safe_dump(payload), encoding="utf-8")
|
||||
return str(path)
|
||||
|
||||
return _write
|
||||
Reference in New Issue
Block a user