Beispiel #1
0
def test_delete():
    FD = FileDistributor(providers, len(providers), 3)
    key = FD.put("test", "data")
    FD.delete("test")
    try:
        FD.get("test", key)
        assert False
    except exceptions.FatalOperationFailure as e:
        assert len(e.failures) == 5
Beispiel #2
0
def test_corrupt_fail():
    FD = FileDistributor(providers, len(providers), 3)
    key = FD.put("test", "data")
    providers[0].wipe()
    providers[1].wipe()
    providers[2].wipe()
    try:
        FD.get("test", key)
        assert False
    except exceptions.FatalOperationFailure as e:
        assert len(e.failures) == 3
Beispiel #3
0
def test_update():
    FD = FileDistributor(providers, len(providers), 3)
    key = FD.put("test", "data")
    key = FD.put("test", "other")
    assert FD.get("test", key) == "other"
Beispiel #4
0
def test_roundtrip_with_key():
    key = generate_key()
    FD = FileDistributor(providers, len(providers), 3)
    FD.put("test", "data", key)
    assert FD.get("test", key) == "data"
Beispiel #5
0
def test_roundtrip():
    FD = FileDistributor(providers, len(providers), 3)
    key = FD.put("test", "data")
    key2 = FD.put("another", "data2")
    assert FD.get("test", key) == "data"
    assert FD.get("another", key2) == "data2"
Beispiel #6
0
def test_missing_providers():
    FD = FileDistributor(providers, len(providers), 3)
    key = FD.put("test", "data")
    FD = FileDistributor(providers[0:3], len(providers), 3)
    assert FD.get("test", key) == "data"
Beispiel #7
0
def test_multiple_sessions():
    FD = FileDistributor(providers, len(providers), 3)
    key = FD.put("test", "data")
    FD = FileDistributor(providers, len(providers), 3)
    assert FD.get("test", key) == "data"
Beispiel #8
0
def test_wrong_key():
    wrong_key = generate_key()
    FD = FileDistributor(providers, len(providers), 3)
    FD.put("test", "data")
    with pytest.raises(exceptions.FatalOperationFailure):
        FD.get("test", wrong_key)