From a9266aa2c05321e773d6323b6de0ed8fab669f9b Mon Sep 17 00:00:00 2001 From: khoaguin Date: Fri, 20 Sep 2024 13:24:58 +0700 Subject: [PATCH] user on low-side submits queries and waiting for approval --- tests/scenarios/bigquery/level_0_test.py | 37 +++++++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/tests/scenarios/bigquery/level_0_test.py b/tests/scenarios/bigquery/level_0_test.py index ee51ab5131a..9fe6ad3429d 100644 --- a/tests/scenarios/bigquery/level_0_test.py +++ b/tests/scenarios/bigquery/level_0_test.py @@ -10,6 +10,7 @@ from helpers.api import run_api_path from helpers.api import set_endpoint_settings from helpers.asserts import result_is +from helpers.code import run_code from helpers.events import Event from helpers.events import EventManager from helpers.events import Scenario @@ -27,6 +28,9 @@ import pytest from unsync import unsync +# syft absolute +import syft as sy + random.seed(42069) @@ -68,7 +72,6 @@ async def guest_user_setup_flow(_, events, user): @unsync_ async def user_low_side_activity(_, events, user, after=None): - # loop: guest user creation is allowed if after: await events.await_for(event_name=after) @@ -78,11 +81,10 @@ async def user_low_side_activity(_, events, user, after=None): user_client = user.client() # submit_code - # request_approval - test_query_path = "bigquery.test_query" + submit_query_path = "bigquery.test_query" await result_is( events, - lambda: len(run_api_path(user_client, test_query_path, sql_query=query_sql())) + lambda: len(run_api_path(user_client, submit_query_path, sql_query=query_sql())) == 10000, matches=True, after=[ @@ -93,13 +95,32 @@ async def user_low_side_activity(_, events, user, after=None): register=Event.USERS_CAN_QUERY_MOCK, ) - # loop: wait for approval + func_name = "test_func" + await result_is( + events, + lambda: run_api_path( + user_client, + submit_query_path, + func_name=func_name, + query=query_sql(), + ), + matches="*Query submitted*", + after=[Event.SUBMIT_QUERY_ENDPOINT_CONFIGURED, Event.USERS_CREATED_CHECKED], + register=Event.USERS_CAN_SUBMIT_QUERY, + ) - # execute code - # get result + # this should fail to complete because no work will be approved or denied + await result_is( + events, + lambda: run_code(user_client, method_name=f"{func_name}*"), + matches=sy.SyftException(public_message="*Your code is waiting for approval*"), + after=[Event.USERS_CAN_SUBMIT_QUERY], + register=Event.USERS_QUERY_NOT_READY, + ) # dump result in a file - pass + + events.register(Event.USER_LOW_SIDE_WAITING_FOR_APPROVAL) @unsync_