Stores
A "Store" enable the global in-memory persistence of Python data for use in multiple requests, including the creation and management of environment variables.
Inspect
It's possible to inspect in real time by clicking on the virtual environment icon.
Access
Manual modification of stores can be done using an echo API.
For this, you can create a temporal request with base URL as https://echo.hoppscotch.io
.
For example
https://echo.hoppscotch.io/{{my_custom_path}}
Now modify the store as needed on script tab
ctx.store.my_var = Decimal('0.1')
ctx.store['my_var_2'] = Decimal('0.2')
Payload pattern
To simplify management as the number of variables increases, you can create a payload
variable. Each request would then take the store with the payload variable as input and produce a payload
variable as output, reducing the overall number of variables stored.
Isolation during tests
By default stores are not isolated when testing. To ensure proper isolation you might either:
- Use
unittest.mock.patch
onzapy.stores.use_store
- Pass a
Store
onZapyRequest.send