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.

Reference

grappa_http.register(engine)[source]

Plugin register function.

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
cookies
elapsed
encoding
headers
json
method
request
status
status_code
url
class grappa_http.adapters.RequestsAdapter(res)[source]

Bases: grappa_http.adapters.base.BaseAdapter

Adapter for requests HTTP client.

body
cookies
elapsed
encoding
headers
json
method
request
status
status_code
static test(res)[source]
url
class grappa_http.adapters.AioHttpAdapter[source]

Bases: grappa_http.adapters.base.BaseAdapter

Response adapter for aiohttp.

Not implemented yet.

static test(res)[source]