Пример #1
0
 def test_widget_client(self):
     data = {"a": [i for i in range(50)]}
     widget = PerspectiveWidget(data, client=True)
     assert widget.table is None
     assert widget._data == data
Пример #2
0
 def test_widget_no_data_with_index(self):
     # should fail
     with raises(PerspectiveError):
         PerspectiveWidget(None, index="a")
Пример #3
0
 def test_widget_load_table(self):
     table = Table({"a": np.arange(0, 50)})
     widget = PerspectiveWidget(table, plugin="x_bar")
     assert widget.plugin == "x_bar"
Пример #4
0
 def test_widget(self):
     data = {"a": np.arange(0, 50)}
     widget = PerspectiveWidget(data, plugin="x_bar")
     assert widget.plugin == "x_bar"
Пример #5
0
 def test_widget_schema_with_index(self):
     widget = PerspectiveWidget({"a": int}, index="a")
     assert widget.table._index == "a"
Пример #6
0
 def test_plugin_widget_load_invalid(self):
     data = {"a": [1, 2, 3], "b": ["a", "b", "c"]}
     with raises(PerspectiveError):
         PerspectiveWidget(data, plugin="?")
Пример #7
0
 def test_plugin_widget_set_all(self):
     data = {"a": [1, 2, 3], "b": ["a", "b", "c"]}
     widget = PerspectiveWidget(data)
     for plugin in Plugin:
         widget.plugin = plugin
         assert widget.plugin == plugin.value
Пример #8
0
 def test_aggregates_widget_set_all(self):
     data = {"a": [1, 2, 3], "b": ["a", "b", "c"]}
     widget = PerspectiveWidget(data)
     for agg in Aggregate:
         widget.aggregates = {"a": agg}
         assert widget.aggregates == {"a": agg.value}
Пример #9
0
 def test_widget_load_view_ignore_limit(self):
     table = Table({"a": np.arange(0, 50)})
     view = table.view()
     widget = PerspectiveWidget(view, plugin="x_bar", limit=1)
     assert widget.table.size() == 50
Пример #10
0
 def test_aggregates_widget_load_invalid(self):
     data = {"a": [1, 2, 3], "b": ["a", "b", "c"]}
     with raises(PerspectiveError):
         PerspectiveWidget(data, aggregates={"a": "?"})
Пример #11
0
 def test_aggregates_widget_setattr_invalid(self):
     data = {"a": [1, 2, 3], "b": ["a", "b", "c"]}
     widget = PerspectiveWidget(data)
     with raises(PerspectiveError):
         widget.aggregates = {"a": "?"}
Пример #12
0
 def test_schema_no_ignore(self):
     psp = PerspectiveWidget(DF2, schema=CUSTOM_SCHEMA)
     assert psp.schema == CUSTOM_SCHEMA_CONVERTED
Пример #13
0
 def test_schema_conversion(self):
     psp = PerspectiveWidget(DF2)
     assert psp.schema == {'index': 'integer', 'date': 'date', 'datetime': 'date', 'float': 'float', 'int': 'integer', 'object': 'string', 'string': 'date'}
 def test_widget_client(self):
     data = {"a": np.arange(0, 50)}
     widget = PerspectiveWidget(data, client=True)
     assert widget.table is None
     assert widget._data == data
Пример #15
0
 def test_plugin_widget_load(self):
     data = {"a": [1, 2, 3], "b": ["a", "b", "c"]}
     widget = PerspectiveWidget(data, plugin=Plugin.XBAR)
     assert widget.plugin == "x_bar"
Пример #16
0
 def test_widget_pass_index(self):
     data = {"a": [1, 2, 3, 1]}
     widget = PerspectiveWidget(data, index="a")
     assert widget.table.size() == 3
Пример #17
0
 def test_plugin_widget_setattr(self):
     data = {"a": [1, 2, 3], "b": ["a", "b", "c"]}
     widget = PerspectiveWidget(data)
     widget.plugin = Plugin.XBAR
     assert widget.plugin == "x_bar"
Пример #18
0
 def test_widget_pass_limit(self):
     data = {"a": np.arange(0, 50)}
     widget = PerspectiveWidget(data, limit=1)
     assert widget.table.size() == 1
Пример #19
0
 def test_plugin_widget_setattr_invalid(self):
     data = {"a": [1, 2, 3], "b": ["a", "b", "c"]}
     widget = PerspectiveWidget(data)
     with raises(PerspectiveError):
         widget.plugin = "?"
Пример #20
0
 def test_widget_pass_options_invalid(self):
     data = {"a": np.arange(0, 50)}
     with raises(PerspectiveError):
         PerspectiveWidget(data, index="index", limit=1)
Пример #21
0
 def test_widget_client_update(self):
     data = {"a": np.arange(0, 50)}
     widget = PerspectiveWidget(data, client=True)
     widget.update(data)
     assert widget.table is None
     assert widget._data == {"a": [i for i in range(50)]}
Пример #22
0
 def test_widget_no_data_with_server(self):
     # should fail
     widget = PerspectiveWidget(None, server=True)
     with raises(PerspectiveError):
         widget._make_load_message()
Пример #23
0
 def test_widget_no_data(self):
     widget = PerspectiveWidget(None, plugin="x_bar", row_pivots=["a"])
     assert widget.plugin == "x_bar"
     assert widget.row_pivots == ["a"]
Пример #24
0
 def test_widget_clear_server(self):
     data = {"a": np.arange(0, 50)}
     widget = PerspectiveWidget(data, server=True)
     widget.clear()
     assert widget.table.size() == 0
Пример #25
0
 def test_widget_schema_with_limit(self):
     widget = PerspectiveWidget({"a": int}, limit=5)
     assert widget.table._limit == 5
Пример #26
0
 def test_widget_replace_server(self):
     data = {"a": np.arange(0, 50)}
     widget = PerspectiveWidget(data, server=True)
     widget.replace({"a": [1]})
     assert widget.table.size() == 1
Пример #27
0
 def test_widget_no_data_with_limit(self):
     # should fail
     with raises(PerspectiveError):
         PerspectiveWidget(None, limit=5)
Пример #28
0
 def test_plugin_widget_load_grid(self):
     data = {"a": [1, 2, 3], "b": ["a", "b", "c"]}
     widget = PerspectiveWidget(data, plugin=Plugin.GRID)
     assert widget.plugin == "datagrid"
Пример #29
0
 def test_widget_load_table_ignore_limit(self):
     table = Table({"a": np.arange(0, 50)})
     widget = PerspectiveWidget(table, limit=1)
     assert widget.table.size() == 50
Пример #30
0
 def test_widget_delete_client(self):
     data = {"a": np.arange(0, 50)}
     widget = PerspectiveWidget(data, client=True)
     mocked_post = partial(mock_post, assert_msg={"cmd": "delete"})
     widget.delete()
     widget.post = MethodType(mocked_post, widget)