Common#

This module contains several functions which are used to run demonstrations in tutorials.

is_interactive_mode()[source]#

Checking whether the tutorial code should be run in interactive mode.

Return type:

bool

Returns:

True if it’s being executed by Jupyter kernel and DISABLE_INTERACTIVE_MODE env variable isn’t set, False otherwise.

check_happy_path(pipeline, happy_path, *, response_comparator=<function BaseModel.__eq__>, printout=False)[source]#

Running tutorial with provided pipeline for provided requests, comparing responses with correct expected responses.

Parameters:
  • pipeline (Pipeline) – The Pipeline instance, that will be used for checking.

  • happy_path (Iterable[Tuple[Union[Message, dict, str], Union[Message, dict, str]]]) – A tuple of (request, response) tuples, so-called happy path, its requests are passed to pipeline and the pipeline responses are compared to its responses.

  • response_comparator – Function that checks reference response (first argument) with the actual response (second argument). Defaults to Message.__eq__.

  • printout (bool) – Whether to print the requests/responses during iteration.