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.

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