def test_textstore_read_raw_data(tmp_path) -> None: wallet_path = os.path.join(tmp_path, "wallet") store = TextStore(wallet_path) try: # No write operation has been done yet on the store. with pytest.raises(FileNotFoundError): store._read_raw_data() # Commit the empty JSON lump to disk. store.write() data = store._read_raw_data() assert data == b'{}' assert not store.is_encrypted() finally: store.close()
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()