def test_combine_ignores_all(self) -> None:
     doc = Document()
     m = SomeModel()
     e = bde.ColumnDataChangedEvent(doc, m, "data", None, [1, 2], "setter",
                                    "invoker")
     e2 = bde.ColumnDataChangedEvent(doc, m, "data", None, [3, 4], "setter",
                                     "invoker")
     assert e.combine(e2) == False
     assert e.cols == [1, 2]
Exemple #2
0
 def test_dispatch(self):
     m = FakeModel()
     e = bde.ColumnDataChangedEvent("doc", m, [1,2], "setter", "invoker")
     e.dispatch(FakeEmptyDispatcher())
     d = FakeFullDispatcher()
     e.dispatch(d)
     assert d.called == ['_document_changed', '_document_patched', '_column_data_changed']
Exemple #3
0
 def test_init(self) -> None:
     m = FakeModel()
     e = bde.ColumnDataChangedEvent("doc", m, [1, 2], "setter", "invoker")
     assert e.document == "doc"
     assert e.column_source == m
     assert e.cols == [1, 2]
     assert e.setter == "setter"
     assert e.callback_invoker == "invoker"
Exemple #4
0
 def test_generate(self, mock_tcds):
     mock_tcds.return_value = "new"
     m = FakeModel()
     e = bde.ColumnDataChangedEvent("doc", m, [1,2], "setter", "invoker")
     refs = dict(foo=10)
     bufs = set()
     r = e.generate(refs, bufs)
     assert r == dict(kind="ColumnDataChanged", column_source="ref", new="new", cols=[1,2])
     assert refs == dict(foo=10)
     assert bufs == set()
 def test_dispatch(self) -> None:
     doc = Document()
     m = SomeModel()
     e = bde.ColumnDataChangedEvent(doc, m, "data", None, [1, 2], "setter",
                                    "invoker")
     e.dispatch(FakeEmptyDispatcher())
     d = FakeFullDispatcher()
     e.dispatch(d)
     assert d.called == [
         '_document_changed', '_document_patched', '_column_data_changed'
     ]
 def test_init(self) -> None:
     doc = Document()
     m = SomeModel()
     e = bde.ColumnDataChangedEvent(doc, m, "data", None, [1, 2], "setter",
                                    "invoker")
     assert e.document == doc
     assert e.model == m
     assert e.attr == "data"
     assert e.cols == [1, 2]
     assert e.setter == "setter"
     assert e.callback_invoker == "invoker"
 def test_to_serializable(self) -> None:
     doc = Document()
     m = SomeModel(data={"col0": [1], "col1": [1, 2], "col2": [1, 2, 3]})
     e = bde.ColumnDataChangedEvent(doc, m, "data", None, ["col1", "col2"],
                                    "setter", "invoker")
     s = Serializer()
     r = s.encode(e)
     assert r == dict(
         kind=e.kind,
         model=m.ref,
         attr="data",
         data=MapRep(type="map",
                     entries=[("col1", [1, 2]), ("col2", [1, 2, 3])]),
         cols=["col1", "col2"],
     )
     assert s.buffers == []
Exemple #8
0
 def test_combine_ignores_all(self) -> None:
     m = FakeModel()
     e = bde.ColumnDataChangedEvent("doc", m, [1, 2], "setter", "invoker")
     e2 = bde.ColumnDataChangedEvent("doc", m, [3, 4], "setter", "invoker")
     assert e.combine(e2) == False
     assert e.cols == [1, 2]