-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_st.py
More file actions
36 lines (24 loc) · 1.04 KB
/
test_st.py
File metadata and controls
36 lines (24 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
from pprint import pprint
import schemathesis as st
from schemathesis.checks import response_schema_conformance, not_a_server_error
from cloudharness_test import apitest_init # include to perform default authorization
app_url = os.environ.get("APP_URL", "http://samples.ch.local/api")
schema = st.from_uri(app_url + "/openapi.json")
@schema.parametrize(endpoint="/error")
def test_api(case):
response = case.call()
pprint(response.__dict__)
assert response.status_code >= 500, "this api errors on purpose"
@schema.parametrize(endpoint="/valid")
def test_bearer(case):
response = case.call()
case.validate_response(response, checks=(response_schema_conformance,))
@schema.parametrize(endpoint="/valid-cookie")
def test_cookie(case):
response = case.call()
case.validate_response(response, checks=(response_schema_conformance,))
@schema.parametrize(endpoint="/sampleresources", method="POST")
def test_response(case):
response = case.call()
case.validate_response(response, checks=(response_schema_conformance,))