def test_widget_eventual_data_with_server(self): # should fail widget = PerspectiveWidget(None, server=True) with raises(PerspectiveError): widget._make_load_message() # then succeed widget.load(Table({"a": np.arange(0, 50)})) load_msg = widget._make_load_message() assert load_msg.to_dict() == { "id": -2, "type": "table", "data": { "table_name": widget.table_name } }
def test_widget_eventual_data(self): table = Table({"a": np.arange(0, 50)}) widget = PerspectiveWidget(None, plugin="x_bar") assert widget.plugin == "x_bar" with raises(PerspectiveError): widget._make_load_message() widget.load(table) load_msg = widget._make_load_message() assert load_msg.to_dict() == { "id": -2, "type": "table", "data": { "table_name": widget.table_name, "options": {} } }
def test_widget_load_table_server(self): table = Table({"a": np.arange(0, 50)}) widget = PerspectiveWidget(table, server=True) load_msg = widget._make_load_message() assert load_msg.to_dict() == { "id": -2, "type": "table", "data": { "table_name": widget.table_name } }
def test_widget_eventual_data_server(self): widget = PerspectiveWidget(None, plugin="x_bar", server=True) assert widget.plugin == "x_bar" widget.load({"a": np.arange(0, 50)}, index="a") load_msg = widget._make_load_message() assert load_msg.to_dict() == { "id": -2, "type": "table", "data": { "table_name": widget.table_name, } }
def test_widget(self): data = {"a": np.arange(0, 50)} widget = PerspectiveWidget(data, plugin="x_bar") assert widget.plugin == "x_bar" load_msg = widget._make_load_message() assert load_msg.to_dict() == { "id": -2, "type": "table", "data": { "table_name": widget.table_name, "options": {} } }
def test_widget_load_table_indexed(self): table = Table({"a": np.arange(0, 50)}, index="a") widget = PerspectiveWidget(table, plugin="x_bar") assert widget.plugin == "x_bar" load_msg = widget._make_load_message() assert load_msg.to_dict() == { "id": -2, "type": "table", "data": { "table_name": widget.table_name, "options": { "index": "a" } } }
def test_widget_load_view(self): table = Table({"a": np.arange(0, 50)}) view = table.view() widget = PerspectiveWidget(view, plugin="x_bar") assert widget.plugin == "x_bar" load_msg = widget._make_load_message() assert load_msg.to_dict() == { "id": -2, "type": "table", "data": { "table_name": widget.table_name, "view_name": widget._perspective_view_name, "options": {} } }
def test_widget_eventual_data_indexed(self): widget = PerspectiveWidget(None, plugin="X Bar") assert widget.plugin == "X Bar" widget.load({"a": np.arange(0, 50)}, index="a") load_msg = widget._make_load_message() assert load_msg.to_dict() == { "id": -2, "type": "table", "data": { "table_name": widget.table_name, "options": { "index": "a" } } }
def test_widget_no_data_with_server(self): # should fail widget = PerspectiveWidget(None, server=True) with raises(PerspectiveError): widget._make_load_message()