def test_concurrent_tx_sees_original_value_on_delete(self, keyfs): D = keyfs.add_key("NAME", "hello", dict) with keyfs.transaction(write=True): D.set({1:2}) tx_1 = Transaction(keyfs, write=True) tx_2 = Transaction(keyfs) tx_1.delete(D) tx_1.commit() assert tx_2.get(D) == {1:2}
def test_concurrent_tx_sees_original_value_on_write(self, keyfs): D = keyfs.add_key("NAME", "hello", dict) tx_1 = Transaction(keyfs, write=True) tx_2 = Transaction(keyfs) ser = tx_1.conn.last_changelog_serial + 1 tx_1.set(D, {1:1}) tx1_serial = tx_1.commit() assert tx1_serial == ser assert tx_2.at_serial == ser - 1 with keyfs._storage.get_connection() as conn: assert conn.last_changelog_serial == ser assert D not in tx_2.cache and D not in tx_2.dirty assert tx_2.get(D) == {}