mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Add test_replay for easily replaying data sent to the sandbox purely within python
Summary: Run JS with a value for SANDBOX_BUFFERS_DIR, then run test_replay in python with the same value to replay just the python code. See test_replay.py for more info. Test Plan: Record some data, e.g. `SANDBOX_BUFFERS_DIR=manual npm start` or `SANDBOX_BUFFERS_DIR=server ./test/testrun.sh server`. Then run `SANDBOX_BUFFERS_DIR=server python -m unittest test_replay` from within `core/sandbox/grist` to replay the input from the JS. Sample of the output will look like this: ``` Checking /tmp/sandbox_buffers/server/2021-06-16T15:13:59.958Z True Checking /tmp/sandbox_buffers/server/2021-06-16T15:16:37.170Z True Checking /tmp/sandbox_buffers/server/2021-06-16T15:14:22.378Z True ``` Reviewers: paulfitz, dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2866
This commit is contained in:
@@ -13,7 +13,7 @@ import six
|
||||
|
||||
from acl_formula import parse_acl_formula
|
||||
import actions
|
||||
import sandbox
|
||||
from sandbox import Sandbox
|
||||
import engine
|
||||
import migrations
|
||||
import schema
|
||||
@@ -23,15 +23,6 @@ import objtypes
|
||||
import logger
|
||||
log = logger.Logger(__name__, logger.INFO)
|
||||
|
||||
def export(method):
|
||||
# Wrap each method so that it logs a message that it's being called.
|
||||
@functools.wraps(method)
|
||||
def wrapper(*args, **kwargs):
|
||||
log.debug("calling %s" % method.__name__)
|
||||
return method(*args, **kwargs)
|
||||
|
||||
sandbox.register(method.__name__, wrapper)
|
||||
|
||||
def table_data_from_db(table_name, table_data_repr):
|
||||
if table_data_repr is None:
|
||||
return actions.TableData(table_name, [], {})
|
||||
@@ -51,9 +42,18 @@ def _decode_db_value(value):
|
||||
else:
|
||||
return value
|
||||
|
||||
def main():
|
||||
def run(sandbox):
|
||||
eng = engine.Engine()
|
||||
|
||||
def export(method):
|
||||
# Wrap each method so that it logs a message that it's being called.
|
||||
@functools.wraps(method)
|
||||
def wrapper(*args, **kwargs):
|
||||
log.debug("calling %s" % method.__name__)
|
||||
return method(*args, **kwargs)
|
||||
|
||||
sandbox.register(method.__name__, wrapper)
|
||||
|
||||
@export
|
||||
def apply_user_actions(action_reprs):
|
||||
action_group = eng.apply_user_actions([useractions.from_repr(u) for u in action_reprs])
|
||||
@@ -114,5 +114,9 @@ def main():
|
||||
|
||||
sandbox.run()
|
||||
|
||||
def main():
|
||||
sandbox = Sandbox.connected_to_js_pipes()
|
||||
run(sandbox)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user