-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from simonsobs/dev
Update tests
- Loading branch information
Showing
13 changed files
with
82 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from unittest.mock import Mock | ||
|
||
from nextline_schedule.auto import AutoMode | ||
from nextline_schedule.graphql import MUTATE_AUTO_MODE_TURN_OFF | ||
from tests.schema.conftest import Schema | ||
|
||
|
||
async def test_schema(schema: Schema) -> None: | ||
auto_mode = Mock(spec=AutoMode) | ||
context_auto_mode = {'auto_mode': auto_mode} | ||
context_value = {'schedule': context_auto_mode} | ||
resp = await schema.execute(MUTATE_AUTO_MODE_TURN_OFF, context_value=context_value) | ||
assert (data := resp.data) | ||
expected = {'schedule': {'autoMode': {'turnOff': True}}} | ||
assert data == expected | ||
auto_mode.turn_off.assert_awaited_once() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from unittest.mock import Mock | ||
|
||
from nextline_schedule.auto import AutoMode | ||
from nextline_schedule.graphql import MUTATE_AUTO_MODE_TURN_ON | ||
from tests.schema.conftest import Schema | ||
|
||
|
||
async def test_schema(schema: Schema) -> None: | ||
auto_mode = Mock(spec=AutoMode) | ||
context_auto_mode = {'auto_mode': auto_mode} | ||
context_value = {'schedule': context_auto_mode} | ||
resp = await schema.execute(MUTATE_AUTO_MODE_TURN_ON, context_value=context_value) | ||
assert (data := resp.data) | ||
expected = {'schedule': {'autoMode': {'turnOn': True}}} | ||
assert data == expected | ||
auto_mode.turn_on.assert_awaited_once() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from string import ascii_letters | ||
from unittest.mock import Mock | ||
|
||
from hypothesis import given, provisional | ||
from hypothesis import strategies as st | ||
|
||
from nextline_schedule.graphql import QUERY_SCHEDULER | ||
from nextline_schedule.scheduler import Scheduler | ||
from nextline_test_utils.strategies import st_graphql_ints | ||
from tests.schema.conftest import Schema | ||
|
||
|
||
@given(d=st.data()) | ||
async def test_schema(d: st.DataObject, schema: Schema) -> None: | ||
api_url = d.draw(provisional.urls()) | ||
length_minutes = d.draw(st_graphql_ints(min_value=1)) | ||
policy = d.draw(st.text(ascii_letters, min_size=1)) | ||
|
||
scheduler = Mock(spec=Scheduler) | ||
scheduler._api_url = api_url | ||
scheduler._length_minutes = length_minutes | ||
scheduler._policy = policy | ||
|
||
context = {'schedule': {'scheduler': scheduler}} | ||
resp = await schema.execute(QUERY_SCHEDULER, context_value=context) | ||
assert (data := resp.data) | ||
|
||
expected = { | ||
'schedule': { | ||
'scheduler': { | ||
'apiUrl': api_url, | ||
'lengthMinutes': length_minutes, | ||
'policy': policy, | ||
} | ||
} | ||
} | ||
assert data == expected |