From 7c232a91f3f21692774dde93edecebbedba7e538 Mon Sep 17 00:00:00 2001 From: Tai Sakuma Date: Mon, 9 Sep 2024 13:02:38 -0400 Subject: [PATCH 1/2] Fix a test --- tests/plugins/ctrl/schema/mutations/test_interrupt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/plugins/ctrl/schema/mutations/test_interrupt.py b/tests/plugins/ctrl/schema/mutations/test_interrupt.py index f07409a..6fffbac 100644 --- a/tests/plugins/ctrl/schema/mutations/test_interrupt.py +++ b/tests/plugins/ctrl/schema/mutations/test_interrupt.py @@ -1,6 +1,7 @@ import asyncio from nextline import Nextline +from strawberry.types import ExecutionResult from nextlinegraphql.plugins.ctrl.graphql import MUTATE_INTERRUPT from tests.plugins.ctrl.schema.conftest import Schema @@ -18,9 +19,12 @@ async def test_schema(schema: Schema) -> None: async with nextline: task = asyncio.create_task(nextline.run_continue_and_wait(started=started)) - await started.wait() + await started.wait() # TODO: Update `started` so that `sleep()` is unnecessary + await asyncio.sleep(1) + result = await schema.execute(MUTATE_INTERRUPT, context_value=context) + assert isinstance(result, ExecutionResult) assert (data := result.data) assert data['ctrl']['interrupt'] is True From c34def6a4fb6561e23523916215a6a07f43384cc Mon Sep 17 00:00:00 2001 From: Tai Sakuma Date: Mon, 9 Sep 2024 13:09:07 -0400 Subject: [PATCH 2/2] Fix type errors --- tests/plugins/ctrl/schema/mutations/test_kill.py | 2 ++ .../ctrl/schema/mutations/test_load_example_script.py | 2 ++ tests/plugins/ctrl/schema/mutations/test_reset.py | 3 +++ tests/plugins/ctrl/schema/mutations/test_terminate.py | 2 ++ tests/plugins/ctrl/schema/queries/test_exception.py | 2 ++ tests/plugins/ctrl/schema/queries/test_source.py | 2 ++ tests/plugins/ctrl/schema/test_run.py | 9 +++++++++ tests/plugins/graphql/schema/queries/test_settings.py | 2 ++ 8 files changed, 24 insertions(+) diff --git a/tests/plugins/ctrl/schema/mutations/test_kill.py b/tests/plugins/ctrl/schema/mutations/test_kill.py index 7c0ce9f..57b1d07 100644 --- a/tests/plugins/ctrl/schema/mutations/test_kill.py +++ b/tests/plugins/ctrl/schema/mutations/test_kill.py @@ -1,6 +1,7 @@ import asyncio from nextline import Nextline +from strawberry.types import ExecutionResult from nextlinegraphql.plugins.ctrl.graphql import MUTATE_KILL from tests.plugins.ctrl.schema.conftest import Schema @@ -21,6 +22,7 @@ async def test_schema(schema: Schema) -> None: await started.wait() result = await schema.execute(MUTATE_KILL, context_value=context) + assert isinstance(result, ExecutionResult) assert (data := result.data) assert data['ctrl']['kill'] is True diff --git a/tests/plugins/ctrl/schema/mutations/test_load_example_script.py b/tests/plugins/ctrl/schema/mutations/test_load_example_script.py index 2fa9983..a924c8d 100644 --- a/tests/plugins/ctrl/schema/mutations/test_load_example_script.py +++ b/tests/plugins/ctrl/schema/mutations/test_load_example_script.py @@ -1,6 +1,7 @@ from pathlib import Path from nextline import Nextline +from strawberry.types import ExecutionResult from nextlinegraphql.plugins.ctrl import example_script as example_script_module from nextlinegraphql.plugins.ctrl.graphql import MUTATE_LOAD_EXAMPLE_SCRIPT @@ -20,6 +21,7 @@ async def test_query(schema: Schema) -> None: async with nextline: context = {'nextline': nextline} result = await schema.execute(MUTATE_LOAD_EXAMPLE_SCRIPT, context_value=context) + assert isinstance(result, ExecutionResult) assert not result.errors assert result.data assert result.data['ctrl']['loadExampleScript'] is True diff --git a/tests/plugins/ctrl/schema/mutations/test_reset.py b/tests/plugins/ctrl/schema/mutations/test_reset.py index 6a1c868..361a258 100644 --- a/tests/plugins/ctrl/schema/mutations/test_reset.py +++ b/tests/plugins/ctrl/schema/mutations/test_reset.py @@ -2,6 +2,7 @@ import pytest from nextline import Nextline +from strawberry.types import ExecutionResult from nextlinegraphql.plugins.ctrl import example_script as example_script_module from nextlinegraphql.plugins.ctrl.graphql import MUTATE_RESET, QUERY_SOURCE @@ -30,10 +31,12 @@ async def test_schema(schema: Schema, statement: str | None) -> None: result = await schema.execute( MUTATE_RESET, context_value=context, variable_values=variables ) + assert isinstance(result, ExecutionResult) assert (data := result.data) assert data['ctrl']['reset'] is True result = await schema.execute(QUERY_SOURCE, context_value=context) + assert isinstance(result, ExecutionResult) assert (data := result.data) expected = statement or example_script diff --git a/tests/plugins/ctrl/schema/mutations/test_terminate.py b/tests/plugins/ctrl/schema/mutations/test_terminate.py index d484692..9b65ecd 100644 --- a/tests/plugins/ctrl/schema/mutations/test_terminate.py +++ b/tests/plugins/ctrl/schema/mutations/test_terminate.py @@ -1,6 +1,7 @@ import asyncio from nextline import Nextline +from strawberry.types import ExecutionResult from nextlinegraphql.plugins.ctrl.graphql import MUTATE_TERMINATE from tests.plugins.ctrl.schema.conftest import Schema @@ -21,6 +22,7 @@ async def test_schema(schema: Schema) -> None: await started.wait() result = await schema.execute(MUTATE_TERMINATE, context_value=context) + assert isinstance(result, ExecutionResult) assert (data := result.data) assert data['ctrl']['terminate'] is True diff --git a/tests/plugins/ctrl/schema/queries/test_exception.py b/tests/plugins/ctrl/schema/queries/test_exception.py index 0791aac..bb7bab0 100644 --- a/tests/plugins/ctrl/schema/queries/test_exception.py +++ b/tests/plugins/ctrl/schema/queries/test_exception.py @@ -1,4 +1,5 @@ from nextline import Nextline +from strawberry.types import ExecutionResult from nextlinegraphql.plugins.ctrl.graphql import QUERY_EXCEPTION from tests.plugins.ctrl.schema.conftest import Schema @@ -16,6 +17,7 @@ async def test_schema(schema: Schema) -> None: await nextline.run_continue_and_wait() result = await schema.execute(QUERY_EXCEPTION, context_value=context) + assert isinstance(result, ExecutionResult) assert (data := result.data) assert "Exception: ('foo', 'bar')" in data['ctrl']['exception'] diff --git a/tests/plugins/ctrl/schema/queries/test_source.py b/tests/plugins/ctrl/schema/queries/test_source.py index db9eff1..b4a4f02 100644 --- a/tests/plugins/ctrl/schema/queries/test_source.py +++ b/tests/plugins/ctrl/schema/queries/test_source.py @@ -2,6 +2,7 @@ import pytest from nextline import Nextline +from strawberry.types import ExecutionResult from syrupy.assertion import SnapshotAssertion from nextlinegraphql.plugins.ctrl import example_script as example_script_module @@ -36,6 +37,7 @@ async def test_schema( result = await schema.execute( QUERY_SOURCE, context_value=context, variable_values=variables ) + assert isinstance(result, ExecutionResult) assert (data := result.data) snapshot.assert_match(data) diff --git a/tests/plugins/ctrl/schema/test_run.py b/tests/plugins/ctrl/schema/test_run.py index 45932af..c188e76 100644 --- a/tests/plugins/ctrl/schema/test_run.py +++ b/tests/plugins/ctrl/schema/test_run.py @@ -5,6 +5,7 @@ from graphql import ExecutionResult as GraphQLExecutionResult from nextline import Nextline from nextline.utils import agen_with_wait +from strawberry.types import ExecutionResult from nextlinegraphql.plugins.ctrl import example_script as example_script_module from nextlinegraphql.plugins.ctrl.graphql import ( @@ -42,6 +43,7 @@ async def test_schema(schema: Schema) -> None: ) result = await schema.execute(QUERY_STATE, context_value=context) + assert isinstance(result, ExecutionResult) assert (data := result.data) assert 'initialized' == data['ctrl']['state'] @@ -54,18 +56,22 @@ async def test_schema(schema: Schema) -> None: await asyncio.sleep(0.01) result = await schema.execute(MUTATE_EXEC, context_value=context) + assert isinstance(result, ExecutionResult) assert (data := result.data) assert data['ctrl']['exec'] result = await schema.execute(QUERY_RUN_NO, context_value=context) + assert isinstance(result, ExecutionResult) assert (data := result.data) assert 1 == data['ctrl']['runNo'] result = await schema.execute(QUERY_TRACE_IDS, context_value=context) + assert isinstance(result, ExecutionResult) assert (data := result.data) data['ctrl']['traceIds'] result = await schema.execute(QUERY_CONTINUOUS_ENABLED, context_value=context) + assert isinstance(result, ExecutionResult) assert (data := result.data) assert False is data['ctrl']['continuousEnabled'] @@ -79,6 +85,7 @@ async def test_schema(schema: Schema) -> None: assert ['initialized', 'running', 'finished'] == states result = await schema.execute(QUERY_STATE, context_value=context) + assert isinstance(result, ExecutionResult) assert (data := result.data) assert 'finished' == data['ctrl']['state'] @@ -175,6 +182,7 @@ async def _control_trace(schema: Schema, context: Any, trace_no: int) -> None: 'fileName': state['fileName'], }, ) + assert isinstance(query_result, ExecutionResult) assert (data := query_result.data) source_line = data['ctrl']['sourceLine'] @@ -190,5 +198,6 @@ async def _control_trace(schema: Schema, context: Any, trace_no: int) -> None: 'traceNo': trace_no, }, ) + assert isinstance(query_result, ExecutionResult) assert (data := query_result.data) assert data['ctrl']['sendPdbCommand'] diff --git a/tests/plugins/graphql/schema/queries/test_settings.py b/tests/plugins/graphql/schema/queries/test_settings.py index 0e2de89..65cd090 100644 --- a/tests/plugins/graphql/schema/queries/test_settings.py +++ b/tests/plugins/graphql/schema/queries/test_settings.py @@ -1,6 +1,7 @@ import json from dynaconf import Dynaconf +from strawberry.types import ExecutionResult from nextlinegraphql.plugins.graphql.graphql import QUERY_SETTINGS from tests.plugins.graphql.schema.conftest import Schema @@ -11,6 +12,7 @@ async def test_settings(schema: Schema) -> None: conf = Dynaconf(**settings) context = {'settings': conf} result = await schema.execute(QUERY_SETTINGS, context_value=context) + assert isinstance(result, ExecutionResult) assert not result.errors assert result.data assert result.data['settings']