Exemplo n.º 1
0
    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
            }
        }
Exemplo n.º 2
0
    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": {}
            }
        }
Exemplo n.º 3
0
 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
         }
     }
Exemplo n.º 4
0
 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,
         }
     }
Exemplo n.º 5
0
 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": {}
         }
     }
Exemplo n.º 6
0
 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"
             }
         }
     }
Exemplo n.º 7
0
 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": {}
         }
     }
Exemplo n.º 8
0
 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"
             }
         }
     }
Exemplo n.º 9
0
 def test_widget_no_data_with_server(self):
     # should fail
     widget = PerspectiveWidget(None, server=True)
     with raises(PerspectiveError):
         widget._make_load_message()