From 2c59c716b94ca9b0f72f195b57ac255761157be9 Mon Sep 17 00:00:00 2001 From: nir Date: Tue, 1 Oct 2024 09:01:26 +0300 Subject: [PATCH] revert wrong refactor --- .../schema_extensions/test_extensions.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/schema/extensions/schema_extensions/test_extensions.py b/tests/schema/extensions/schema_extensions/test_extensions.py index 5bec8c9d9a..264c97f2cc 100644 --- a/tests/schema/extensions/schema_extensions/test_extensions.py +++ b/tests/schema/extensions/schema_extensions/test_extensions.py @@ -133,7 +133,7 @@ def test_extension_access_to_errors(): execution_errors = [] class MyExtension(SchemaExtension): - def on_parse(self, execution_context: ExecutionContext): + def on_operation(self, execution_context: ExecutionContext): nonlocal execution_errors yield execution_errors = execution_context.errors @@ -168,7 +168,7 @@ def test_extension_access_to_root_value(): root_value = None class MyExtension(SchemaExtension): - def on_parse(self, execution_context: ExecutionContext): + def on_operation(self, execution_context: ExecutionContext): nonlocal root_value yield root_value = execution_context.root_value @@ -194,7 +194,7 @@ class CustomizableExtension(SchemaExtension): def __init__(self, arg: int): self.arg = arg - def on_parse(self, execution_context: ExecutionContext): + def on_operation(self, execution_context: ExecutionContext): yield execution_context.result.data = {"override": self.arg} @@ -212,7 +212,7 @@ def on_parse(self, execution_context: ExecutionContext): @pytest.fixture() def sync_extension() -> Type[ExampleExtension]: class MyExtension(ExampleExtension): - def on_parse(self, execution_context: ExecutionContext): + def on_operation(self, execution_context: ExecutionContext): with hook_wrap(self.called_hooks, SchemaExtension.on_operation.__name__): yield @@ -258,7 +258,7 @@ async def test_mixed_sync_and_async_extension_hooks( default_query_types_and_query, sync_extension ): class MyExtension(sync_extension): - async def on_parse(self, execution_context: ExecutionContext): + async def on_operation(self, execution_context: ExecutionContext): with hook_wrap(self.called_hooks, SchemaExtension.on_operation.__name__): yield @@ -294,7 +294,7 @@ def register_hook(hook_name: str, klass: type): called_hooks.append(f"{klass.__name__}, {hook_name} Exited") class ExtensionA(ExampleExtension): - async def on_parse(self, execution_context: ExecutionContext): + async def on_operation(self, execution_context: ExecutionContext): with register_hook(SchemaExtension.on_operation.__name__, ExtensionA): yield @@ -311,7 +311,7 @@ def on_execute(self, execution_context: ExecutionContext): yield class ExtensionB(ExampleExtension): - async def on_parse(self, execution_context: ExecutionContext): + async def on_operation(self, execution_context: ExecutionContext): with register_hook(SchemaExtension.on_operation.__name__, ExtensionB): yield @@ -374,7 +374,7 @@ class SyncExt(ExampleExtension): f"{SchemaExtension.on_parse.__name__} Entered", ] - def on_parse(self, execution_context: ExecutionContext): + def on_operation(self, execution_context: ExecutionContext): self.called_hooks.append(self.__class__.expected[0]) async def on_parse(self, execution_context: ExecutionContext): @@ -897,7 +897,7 @@ def test_extend_error_format_example(): # Test that the example of how to extend error format class ExtendErrorFormat(SchemaExtension): - def on_parse(self, execution_context: ExecutionContext): + def on_operation(self, execution_context: ExecutionContext): yield result = execution_context.result if getattr(result, "errors", None): @@ -937,7 +937,7 @@ def ping(self) -> str: def test_extension_can_set_query(): class MyExtension(SchemaExtension): - def on_parse(self, execution_context: ExecutionContext): + def on_operation(self, execution_context: ExecutionContext): execution_context.query = "{ hi }" yield @@ -961,7 +961,7 @@ def hi(self) -> str: @pytest.mark.asyncio async def test_extension_can_set_query_async(): class MyExtension(SchemaExtension): - def on_parse(self, execution_context: ExecutionContext): + def on_operation(self, execution_context: ExecutionContext): execution_context.query = "{ hi }" yield