test_utils module

Testing helper functions to store common pytest and xray publishing functionality.

aiv_utils.test_utils.dump_locals(*variables)

Display the named local variables as a JSON object.

Params variables:

names of local variables to include in JSON output

aiv_utils.test_utils.generate_obs(number_of_obs=1, duration=0.5, start_chan=96, stop_chan=143, num_beams=1)

Generate and return a list of obs using given configuration.

Return type:

list[dict[str, str | int | float | list[dict]]]

aiv_utils.test_utils.get_pod_logs(device_pod_name, device_pod_namespace, from_time, core_v1_api=None)

Grab the Kubernetes pod logs from the input device’s pod name.

Params device_pod_name:

The lubernetes pod name for a tango device.

Params from_time:

The datatime object to get logs from.

aiv_utils.test_utils.get_pod_name(tango_device)

Return the Kubernetes pod name for a given Tango device.

Params tango_device:

The Tango device.

Return type:

tuple[str, str]

aiv_utils.test_utils.grab_tagged_cell_json(notebook, tag)

Grab the JSON content of the cell tagged with the input tag.

There must be only one cell with the tag, and only one output with with application/json data in that cell.

Params notebook:

The output object of a papermill run

Params tag:

The tag the cell has been given

Return type:

Any

Returns:

The tagged cell’s text output parsed as JSON

aiv_utils.test_utils.grab_tagged_cell_text(notebook, tag)

Grab the text of a papermill notebook cell with the input tag.

The output includes all display output of type text/plain and all stream output, e.g. from stdout and stderr.

Params notebook:

The output object of a papermill run

Params tag:

The tag the cell has been given

Return cell_string:

The output string of the tagged cell

Return type:

str

aiv_utils.test_utils.make_test_dir(dir_prefix='test', base_dir='build/test_runs', start_time=None)

Create a directory for the test runs of the notebooks to be output to.

Params dir_prefix:

The prefix of the test directory, default is test

Params base_dir:

The base directory that the test directory will be made in, the default is build/test_runs

Params start_time:

The start time of the pytest run in the format ‘%Y-%m-%d_%H:%M:%S’

Return type:

str