1+ import os
12import pytest
3+ from pytest import Config
24import schemathesis
35from typing import Generator , Any
46from 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 ()
271275def 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