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
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
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"
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"
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"
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"
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"
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)