massdash.testing.PlotlySnapshotExtension

class massdash.testing.PlotlySnapshotExtension

Bases: SingleFileSnapshotExtension

Handles Plotly Snapshots. Snapshots are stored as json files and the json output from the files are compared.

static compare_json(json1, json2) bool

Compare two plotly json objects. This function acts recursively

Parameters:
  • json1 – first json

  • json2 – second json

Returns:

True if the objects are equal, False otherwise

Return type:

bool

matches(*, serialized_data, snapshot_data)

Compares serialized data and snapshot data and returns whether they match.

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 data to a json string

Parameters:

data (SerializableData) – plotly data to serialize

Returns:

json string of plotly plot

Return type:

str

classmethod write_snapshot_collection(*, snapshot_collection: SnapshotCollection) None

Adds the snapshot data to the snapshots in collection location