Skip to content

Commit 05d3e06

Browse files
committed
#700 django specific api template
1 parent 392fc28 commit 05d3e06

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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

0 commit comments

Comments
 (0)