示例#1
0
def test_textstore_load_data_valid(tmp_path) -> None:
    wallet_path = os.path.join(tmp_path, "wallet")
    store = TextStore(wallet_path)
    try:
        store.load_data(b"{}")
    finally:
        store.close()
示例#2
0
def test_textstore_load_data_valid() -> None:
    wallet_path = tempfile.mktemp()
    store = TextStore(wallet_path)
    try:
        store.load_data(b"{}")
    finally:
        store.close()
示例#3
0
def test_store_load_data_invalid(tmp_path) -> None:
    wallet_path = os.path.join(tmp_path, "wallet")
    store = TextStore(wallet_path)
    try:
        with pytest.raises(OSError):
            store.load_data(b"x{}")
    finally:
        store.close()
示例#4
0
def test_store_load_data_invalid() -> None:
    wallet_path = tempfile.mktemp()
    store = TextStore(wallet_path)
    try:
        with pytest.raises(OSError):
            store.load_data(b"x{}")
    finally:
        store.close()
示例#5
0
def test_store__write(tmp_path) -> None:
    wallet_path = os.path.join(tmp_path, "wallet")
    store = TextStore(wallet_path)
    try:
        assert not store.is_primed()
        store.put("number", 10)
        store._write()
        assert store.is_primed()
        # This will raise an assertion if there is not locatible JSON lump.
        store._read_raw_data()
        assert store.get("number") == 10
    finally:
        store.close()

    store = TextStore(wallet_path)
    try:
        assert store.is_primed()
        # We need to do this here because the wallet storage normally does it.
        store.load_data(store._read_raw_data())
        assert store.get("number") == 10
    finally:
        store.close()