Beispiel #1
0
 def test_import_changes_subscriber_error(self, keyfs, storage, tmpdir):
     pkey = keyfs.add_key("NAME", "hello/{name}", dict)
     D = pkey(name="world")
     with keyfs.transaction(write=True):
         D.set({1:1})
     new_keyfs = KeyFS(tmpdir.join("newkeyfs"), storage)
     pkey = new_keyfs.add_key("NAME", "hello/{name}", dict)
     new_keyfs.subscribe_on_import(pkey, lambda *args: 0/0)
     serial = new_keyfs.get_current_serial()
     with keyfs.transaction() as tx:
         changes = tx.conn.get_changes(0)
     with pytest.raises(ZeroDivisionError):
         new_keyfs.import_changes(0, changes)
     assert new_keyfs.get_current_serial() == serial
Beispiel #2
0
 def test_import_changes_subscriber(self, keyfs, storage, tmpdir):
     pkey = keyfs.add_key("NAME", "hello/{name}", dict)
     D = pkey(name="world")
     with keyfs.transaction(write=True):
         D.set({1:1})
     assert keyfs.get_current_serial() == 0
     # load entries into new keyfs instance
     new_keyfs = KeyFS(tmpdir.join("newkeyfs"), storage)
     pkey = new_keyfs.add_key("NAME", "hello/{name}", dict)
     l = []
     new_keyfs.subscribe_on_import(pkey, lambda *args: l.append(args))
     with keyfs.transaction() as tx:
         changes = tx.conn.get_changes(0)
     new_keyfs.import_changes(0, changes)
     assert l[0][1:] == (new_keyfs.NAME(name="world"), {1:1}, -1)