Skip to content

Commit 52c69af

Browse files
committed
update to statefulapi calls due to latest changes in schemathesis version
1 parent a21ceb3 commit 52c69af

File tree

3 files changed

+619
-607
lines changed

3 files changed

+619
-607
lines changed

schemathesis.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
base-url = "https://${API_HOST}"

tests/model_registry/conftest.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import os
12
import pytest
3+
from pytest import Config
24
import schemathesis
35
from typing import Generator, Any
46
from ocp_resources.pod import Pod
@@ -259,15 +261,17 @@ def model_registry_instance_rest_endpoint(
259261

260262

261263
@pytest.fixture(scope="class")
262-
def generated_schema(model_registry_instance_rest_endpoint: str) -> BaseOpenAPISchema:
264+
def generated_schema(pytestconfig: Config, model_registry_instance_rest_endpoint: str) -> BaseOpenAPISchema:
265+
os.environ["API_HOST"] = model_registry_instance_rest_endpoint
266+
config = schemathesis.config.SchemathesisConfig.from_path(f"{pytestconfig.rootpath}/schemathesis.toml")
263267
schema = schemathesis.openapi.from_url(
264-
url="https://raw.githubusercontent.com/kubeflow/model-registry/main/api/openapi/model-registry.yaml"
268+
url="https://raw.githubusercontent.com/kubeflow/model-registry/main/api/openapi/model-registry.yaml",
269+
config=config,
265270
)
266-
schema.configure(base_url=f"https://{model_registry_instance_rest_endpoint}/")
267271
return schema
268272

269273

270-
@pytest.fixture
274+
@pytest.fixture()
271275
def state_machine(generated_schema: BaseOpenAPISchema, current_client_token: str) -> APIStateMachine:
272276
BaseAPIWorkflow = generated_schema.as_state_machine()
273277

@@ -277,12 +281,18 @@ class APIWorkflow(BaseAPIWorkflow): # type: ignore
277281
def setup(self) -> None:
278282
self.headers = {"Authorization": f"Bearer {current_client_token}", "Content-Type": "application/json"}
279283

284+
def before_call(self, case: Case) -> None:
285+
LOGGER.info(f"Checking: {case.method} {case.path}")
286+
280287
# these kwargs are passed to requests.request()
281288
def get_call_kwargs(self, case: Case) -> dict[str, Any]:
282289
return {"verify": False, "headers": self.headers}
283290

284291
def after_call(self, response: Response, case: Case) -> None:
285-
LOGGER.info(f"{case.method} {case.path} -> {response.status_code}")
292+
LOGGER.info(
293+
f"Method tested: {case.method}, API: {case.path}, response code:{response.status_code},"
294+
f" Full Response:{response.text}"
295+
)
286296

287297
return APIWorkflow
288298

0 commit comments

Comments
 (0)