Additional Abilities

ScreenPy Requests adds one additional Ability, which enables Actors to use Requests to make API requests.

MakeAPIRequests

class MakeAPIRequests(session: Session | None = None)

Use Requests to enable sending API requests.

Examples:

Perry = AnActor.named("Perry").who_can(MakeAPIRequests())

Perry = AnActor.named("Perry").who_can(
    MakeAPIRequests.using(session_instance)
)
static using(session: Session) MakeAPIRequests

Provide a Requests session for the Ability to use.

to_send(method: str, url: str, **kwargs: Any) None

Send a request.

This is a pass-through to the session’s request method and has the same parameter signature. The response is stored in this Ability.

Args:

method: the HTTP method of the request - GET, POST, etc. url: the URL to which to send the request. kwargs: additional keyword arguments to pass through to Session.request.

send(method: str, url: str, **kwargs: Any) None

Send a request.

This is a pass-through to the session’s request method and has the same parameter signature. The response is stored in this Ability.

Args:

method: the HTTP method of the request - GET, POST, etc. url: the URL to which to send the request. kwargs: additional keyword arguments to pass through to Session.request.