Example #1
0
def test_the_first_read_after_write(locker: DistributedRWLockManager,
                                    on_done1: OnLockCallback,
                                    on_done2: OnLockCallback):
    locker.acquire_write_lock(NODE1, on_done1)
    locker.acquire_read_lock(NODE1, on_done2)

    on_done2.assert_not_called()
Example #2
0
def test_the_read_locks_compat(locker: DistributedRWLockManager,
                               on_done1: OnLockCallback,
                               on_done2: OnLockCallback):
    locker.acquire_read_lock(NODE1, on_done1)
    locker.acquire_read_lock(NODE1, on_done2)

    on_done2.assert_called_once_with(NODE1, ANY)
Example #3
0
def test_the_independent_writes(locker: DistributedRWLockManager,
                                on_done1: OnLockCallback,
                                on_done2: OnLockCallback):

    locker.acquire_write_lock(NODE1, on_done1)
    locker.acquire_write_lock(NODE2, on_done2)

    on_done1.assert_called_once_with(NODE1, ANY)
    on_done2.assert_called_once_with(NODE2, ANY)
Example #4
0
def test_the_first_write_after_write(locker: DistributedRWLockManager,
                                     on_done1: OnLockCallback,
                                     on_done2: OnLockCallback):
    locker.acquire_write_lock(NODE1, on_done1)
    locker.acquire_write_lock(NODE1, on_done2)

    on_done2.assert_not_called()

    lock1 = get_lock(on_done1)
    lock1.release()

    on_done2.assert_called_once_with(NODE1, ANY)
Example #5
0
def test_mutable_has_no_effect(locker: DistributedRWLockManager,
                               on_done1: OnLockCallback,
                               on_done2: OnLockCallback):
    state = {"foo": "bar"}

    locker.acquire_write_lock(state, on_done1)
    locker.acquire_write_lock(state, on_done2)

    state["foo"] = "not bar"

    lock1 = get_lock(on_done1)
    lock1.release()
    on_done2.assert_called_once_with(state, ANY)
Example #6
0
def test_the_first_one_write_lock(locker: DistributedRWLockManager,
                                  on_done1: OnLockCallback):
    locker.acquire_write_lock(NODE1, on_done1)

    on_done1.assert_called_once_with(NODE1, ANY)