1+ import os
12import pytest
3+ from pytest import Config
24import schemathesis
35from typing import Generator , Any
46from ocp_resources .pod import Pod
@@ -269,15 +271,17 @@ def model_registry_instance_rest_endpoint(
269271
270272
271273@pytest .fixture (scope = "class" )
272- def generated_schema (model_registry_instance_rest_endpoint : str ) -> BaseOpenAPISchema :
274+ def generated_schema (pytestconfig : Config , model_registry_instance_rest_endpoint : str ) -> BaseOpenAPISchema :
275+ os .environ ["API_HOST" ] = model_registry_instance_rest_endpoint
276+ config = schemathesis .config .SchemathesisConfig .from_path (f"{ pytestconfig .rootpath } /schemathesis.toml" )
273277 schema = schemathesis .openapi .from_url (
274- url = "https://raw.githubusercontent.com/kubeflow/model-registry/main/api/openapi/model-registry.yaml"
278+ url = "https://raw.githubusercontent.com/kubeflow/model-registry/main/api/openapi/model-registry.yaml" ,
279+ config = config ,
275280 )
276- schema .configure (base_url = f"https://{ model_registry_instance_rest_endpoint } /" )
277281 return schema
278282
279283
280- @pytest .fixture
284+ @pytest .fixture ()
281285def state_machine (generated_schema : BaseOpenAPISchema , current_client_token : str ) -> APIStateMachine :
282286 BaseAPIWorkflow = generated_schema .as_state_machine ()
283287
@@ -287,12 +291,18 @@ class APIWorkflow(BaseAPIWorkflow): # type: ignore
287291 def setup (self ) -> None :
288292 self .headers = {"Authorization" : f"Bearer { current_client_token } " , "Content-Type" : "application/json" }
289293
294+ def before_call (self , case : Case ) -> None :
295+ LOGGER .info (f"Checking: { case .method } { case .path } " )
296+
290297 # these kwargs are passed to requests.request()
291298 def get_call_kwargs (self , case : Case ) -> dict [str , Any ]:
292299 return {"verify" : False , "headers" : self .headers }
293300
294301 def after_call (self , response : Response , case : Case ) -> None :
295- LOGGER .info (f"{ case .method } { case .path } -> { response .status_code } " )
302+ LOGGER .info (
303+ f"Method tested: { case .method } , API: { case .path } , response code:{ response .status_code } ,"
304+ f" Full Response:{ response .text } "
305+ )
296306
297307 return APIWorkflow
298308
0 commit comments