File tree Expand file tree Collapse file tree
application-templates/django-app/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import os
2+ from pprint import pprint
3+ import schemathesis as st
4+ from schemathesis .checks import response_schema_conformance , not_a_server_error
5+
6+ from cloudharness_test import apitest_init # include to perform default authorization
7+
8+ app_url = os .environ .get ("APP_URL" , "http://samples.ch.local/api" )
9+
10+ try :
11+ schema = st .from_uri (app_url + "/openapi.json" )
12+ except :
13+ # support alternative schema location
14+ schema = st .from_uri (app_url .replace ("/api" , "" ) + "/openapi.json" )
15+
16+
17+ @schema .parametrize (endpoint = "/ping" )
18+ def test_ping (case ):
19+ response = case .call ()
20+ pprint (response .__dict__ )
21+ assert response .status_code == 200 , "this api errors on purpose"
22+
23+ def test_state_machine ():
24+ schema .as_state_machine ().run ()
25+ # APIWorkflow = schema.as_state_machine()
26+ # APIWorkflow.run()
27+ # TestAPI = APIWorkflow.TestCase
You can’t perform that action at this time.
0 commit comments