Example #1
0
def test_lock_validate_conflict():
    """ _lock.validate raise exception on conflicting locks """
    lock1 = _test.Bunch(name='foo', exclusive=True)
    lock2 = _test.Bunch(name='baz', exclusive=False)
    lock3 = _test.Bunch(name='foo', exclusive=False)
    lock4 = _test.Bunch(name='bar', exclusive=True)

    with assert_raises(_lock.LockConflict):
        _lock.validate([lock1, lock2, lock3, lock4])
Example #2
0
def test_lock_validate_happy():
    """ _lock.validate returns ordered, squashed list of locks """
    lock1 = _test.Bunch(name='foo', exclusive=True)
    lock2 = _test.Bunch(name='baz', exclusive=False)
    lock3 = _test.Bunch(name='foo', exclusive=True)
    lock4 = _test.Bunch(name='bar', exclusive=True)

    result = _lock.validate([lock1, lock2, lock3, lock4])
    assert_equals(result, [lock4, lock2, lock1])
Example #3
0
def test_lock_validate_empty():
    """ _lock.validate returns empty list for empty sequence """
    assert_equals([], _lock.validate(iter(())))
Example #4
0
def test_lock_validate_none():
    """ _lock.validate returns empty list for None """
    assert_equals([], _lock.validate(None))