API¶
grappa_http provides HTTP protocol assertion for grappa testing library.
Example:
import grappa
import grappa_http
# Register plugin
grappa.use(grappa_http)
# Use plugin assertion
res = requests.get('httpbin.org/status/204')
res | should.have.status(204)
For assertion operators and aliases, see operators documentation.
-
grappa_http.adapters.
match
(res)[source]¶ Match adapter based on response object using type inference.
Parameters: res (mixed) – HTTP client specific response object to infer. Returns: grappa_http.adapters.BaseAdapter
-
grappa_http.adapters.
use_adapter
(*_adapters)[source]¶ Adds one or multiple custom HTTP client adapters for testing introspection.
Parameters: *adapters (grappa_http.BaseAdapter) – adapter or adapters to use.
-
class
grappa_http.adapters.
BaseAdapter
[source]¶ Bases:
object
BaseAdapter implements.
-
body
¶
-
elapsed
¶
-
encoding
¶
-
headers
¶
-
json
¶
-
method
¶
-
request
¶
-
status
¶
-
status_code
¶
-
url
¶
-