Exemple #1
0
 def callback(port_id, delta):
     assert port_id in ports_to_update
     _t = Table(delta)
     _v = _t.view()
     assert _v.to_records() == unique_data[port]
     _v.delete()
     _t.delete()
Exemple #2
0
    def test_table_delete_callback(self, sentinel):
        s = sentinel(False)

        def callback():
            s.set(True)
        data = [{"a": 1, "b": 2}, {"a": 3, "b": 4}]
        tbl = Table(data)
        tbl.on_delete(callback)
        tbl.delete()
        assert s.get() is True
Exemple #3
0
    def test_table_delete_callback(self):
        sentinel = False

        def callback():
            nonlocal sentinel
            sentinel = True
        data = [{"a": 1, "b": 2}, {"a": 3, "b": 4}]
        tbl = Table(data)
        tbl.on_delete(callback)
        tbl.delete()
        assert sentinel == True
Exemple #4
0
    def test_table_delete(self):
        process = psutil.Process(os.getpid())
        mem = process.memory_info().rss
        for x in range(10000):
            data = [{"a": 1, "b": 2}, {"a": 3, "b": 4}]
            tbl = Table(data)
            tbl.delete()

        mem2 = process.memory_info().rss

        # assert 1 < (max2 / max) < 1.01
        assert (mem2 - mem) < 2000000
Exemple #5
0
    def test_table_remove_delete_callback(self, sentinel):
        s = sentinel(False)

        def callback():
            s.set(True)

        tbl = Table([{"a": 1}])
        tbl.on_delete(callback)
        tbl.remove_delete(callback)

        tbl.delete()

        assert s.get() is False
Exemple #6
0
    def test_table_delete_with_view(self, sentinel):
        data = [{"a": 1, "b": 2}, {"a": 3, "b": 4}]
        tbl = Table(data)

        process = psutil.Process(os.getpid())
        mem = process.memory_info().rss
        for x in range(10000):
            view = tbl.view()
            view.delete()

        tbl.delete()
        mem2 = process.memory_info().rss
        assert (mem2 - mem) < 2000000
Exemple #7
0
    def test_table_remove_delete_callback(self):
        sentinel = False

        def callback():
            nonlocal sentinel
            sentinel = True

        tbl = Table([{"a": 1}])
        tbl.on_delete(callback)
        tbl.remove_delete(callback)

        tbl.delete()

        assert sentinel == False
Exemple #8
0
    def test_view_remove_delete_callback(self, sentinel):
        s = sentinel(False)

        def callback():
            s.set(True)

        tbl = Table([{"a": 1}])
        view = tbl.view()

        view.on_delete(callback)
        view.remove_delete(callback)

        view.delete()
        tbl.delete()

        assert s.get() is False
Exemple #9
0
    def test_view_remove_delete_callback(self):
        sentinel = False

        def callback():
            nonlocal sentinel
            sentinel = True

        tbl = Table([{"a": 1}])
        view = tbl.view()

        view.on_delete(callback)
        view.remove_delete(callback)

        view.delete()
        tbl.delete()

        assert sentinel == False
Exemple #10
0
    def test_table_delete_multiple_callback(self, sentinel):
        s1 = sentinel(False)
        s2 = sentinel(False)

        def callback1():
            s1.set(True)

        def callback2():
            s2.set(True)

        tbl = Table([{"a": 1}])
        tbl.on_delete(callback1)
        tbl.on_delete(callback2)

        tbl.delete()

        assert s1.get() is True
        assert s2.get() is True
Exemple #11
0
    def test_table_delete_multiple_callback(self):
        sentinel1 = False
        sentinel2 = False

        def callback1():
            nonlocal sentinel1
            sentinel1 = True

        def callback2():
            nonlocal sentinel2
            sentinel2 = True

        tbl = Table([{"a": 1}])
        tbl.on_delete(callback1)
        tbl.on_delete(callback2)

        tbl.delete()

        assert sentinel1 == True
        assert sentinel2 == True
Exemple #12
0
 def test_table_delete(self):
     data = [{"a": 1, "b": 2}, {"a": 3, "b": 4}]
     tbl = Table(data)
     tbl.delete()