Skip to content

Commit

Permalink
Merge pull request #107 from simonsobs/dev
Browse files Browse the repository at this point in the history
Fix errors in GitHub Actions workflows
  • Loading branch information
TaiSakuma authored Sep 9, 2024
2 parents 92ff038 + c34def6 commit 787e447
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/plugins/ctrl/schema/mutations/test_interrupt.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
2 changes: 2 additions & 0 deletions tests/plugins/ctrl/schema/mutations/test_kill.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tests/plugins/ctrl/schema/mutations/test_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/plugins/ctrl/schema/mutations/test_terminate.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
2 changes: 2 additions & 0 deletions tests/plugins/ctrl/schema/queries/test_exception.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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']
2 changes: 2 additions & 0 deletions tests/plugins/ctrl/schema/queries/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
9 changes: 9 additions & 0 deletions tests/plugins/ctrl/schema/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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']

Expand All @@ -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']

Expand All @@ -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']

Expand Down Expand Up @@ -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']

Expand All @@ -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']
2 changes: 2 additions & 0 deletions tests/plugins/graphql/schema/queries/test_settings.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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']
Expand Down

0 comments on commit 787e447

Please sign in to comment.