def test_acquire_lock(tmpdir):
    locked_file = tmpdir.join("locked_file")
    locked_file.write("")

    path = "%s" % locked_file

    assert store.have_lock(path) == False
    store.aquire_lock(path)
    assert store.have_lock(path) == True
def test_load_data_from_file_locking(tmpdir):
    locked_file = tmpdir.join("locked_file")
    locked_file.write("[1, 2]")

    data = store.load_data_from_file("%s" % locked_file, lock=True)
    assert data == [1, 2]
    assert store.have_lock("%s" % locked_file) == True
def test_release_all_locks(tmpdir):
    locked_file1 = tmpdir.join("locked_file1")
    locked_file1.write("")
    locked_file2 = tmpdir.join("locked_file2")
    locked_file2.write("")

    path1 = "%s" % locked_file1
    path2 = "%s" % locked_file2

    assert store.have_lock(path1) == False
    store.aquire_lock(path1)
    assert store.have_lock(path1) == True

    assert store.have_lock(path2) == False
    store.aquire_lock(path2)
    assert store.have_lock(path2) == True

    store.release_all_locks()
    assert store.have_lock(path1) == False
    assert store.have_lock(path2) == False
def test_load_data_not_locked(tmpdir):
    locked_file = tmpdir.join("locked_file")
    locked_file.write("[1, 2]")

    data = store.load_data_from_file("%s" % locked_file)
    assert store.have_lock("%s" % locked_file) == False