def test_save_restore(self): table = Table({"a": [1, 2, 3]}) viewer = PerspectiveViewer(plugin="x_bar", filters=[["a", "==", 2]], editable=True, expressions=['"a" * 2']) viewer.load(table) # Save config config = viewer.save() assert viewer.filters == [["a", "==", 2]] assert config["filters"] == [["a", "==", 2]] assert viewer.plugin == "x_bar" assert config["plugin"] == "x_bar" assert config["editable"] is True assert config["expressions"] == ['"a" * 2'] # reset configuration viewer.reset() assert viewer.plugin == "datagrid" assert viewer.filters == [] assert viewer.editable is False assert viewer.expressions == [] # restore configuration viewer.restore(**config) assert viewer.filters == [["a", "==", 2]] assert viewer.plugin == "x_bar" assert viewer.editable is True assert viewer.expressions == ['"a" * 2']
def test_save_restore_plugin_config(self): viewer = PerspectiveViewer( plugin="Datagrid", plugin_config={"columns": { "a": { "fixed": 4 } }}) config = viewer.save() assert config["plugin_config"] == {"columns": {"a": {"fixed": 4}}} viewer.reset() assert viewer.plugin_config == {} viewer.restore(**config) assert viewer.plugin_config == config["plugin_config"]
def test_save_restore(self): table = Table({"a": [1, 2, 3]}) viewer = PerspectiveViewer(plugin="x_bar", filters=[["a", "==", 2]]) viewer.load(table) # Save config config = viewer.save() assert viewer.filters == [["a", "==", 2]] assert config["filters"] == [["a", "==", 2]] assert viewer.plugin == "x_bar" assert config["plugin"] == "x_bar" # reset configuration viewer.reset() assert viewer.plugin == "hypergrid" assert viewer.filters == [] # restore configuration viewer.restore(**config) assert viewer.filters == [["a", "==", 2]] assert viewer.plugin == "x_bar"