massdash.testing.BokehSnapshotExtension

class massdash.testing.BokehSnapshotExtension

Bases: SingleFileSnapshotExtension

Handles Bokeh Snapshots. Snapshots are stored as html files and the bokeh .json output from the html files are compared.

static compare_json(json1, json2)

Compare two bokeh json objects. This function acts recursively

Parameters:
  • json1 – first object

  • json2 – second object

Returns:

True if the objects are equal, False otherwise

Return type:

bool

extract_bokeh_json(html: str) <module 'json' from '/home/docs/.asdf/installs/python/3.11.12/lib/python3.11/json/__init__.py'>

Extract the bokeh json from the html file.

Parameters:

html (str) – string containing the html data

Returns:

bokeh json found in the html

Return type:

json

matches(*, serialized_data, snapshot_data)

Determine if the serialized data matches the snapshot data.

Parameters:
  • serialized_data – Data produced by the test

  • snapshot_data – Saved data from a previous test run

read_snapshot_data_from_location(*, snapshot_location: str, snapshot_name: str, session_id: str)

Get only the snapshot data from location for assertion

serialize(data: Any, **kwargs: Any) str

Serialize the bokeh plot as an html string (which is output to a file)

Parameters:

data (SerializableData) – Data to serialize

Returns:

html string

Return type:

str

classmethod write_snapshot_collection(*, snapshot_collection: SnapshotCollection) None

Adds the snapshot data to the snapshots in collection location