Differential D8684 Diff 40813 examples/docs_snippets/docs_snippets_tests/concepts_tests/types_tests/test_types.py
Changeset View
Changeset View
Standalone View
Standalone View
examples/docs_snippets/docs_snippets_tests/concepts_tests/types_tests/test_types.py
import pytest | import pytest | ||||
from dagster import DagsterTypeCheckDidNotPass, execute_solid | from dagster import DagsterTypeCheckDidNotPass, execute_solid | ||||
from docs_snippets.concepts.types.types import test_dagster_type | from docs_snippets.concepts.types.types import test_dagster_type | ||||
def test_basic_even_type(): | def test_basic_even_type(): | ||||
from docs_snippets.concepts.types.types import double_even | from docs_snippets.concepts.types.types import double_even | ||||
assert execute_solid(double_even, input_values={"num": 2}).success | assert execute_solid(double_even, input_values={"num": 2}).success | ||||
with pytest.raises(DagsterTypeCheckDidNotPass): | with pytest.raises(DagsterTypeCheckDidNotPass): | ||||
execute_solid(double_even, input_values={"num": 3}) | execute_solid(double_even, input_values={"num": 3}) | ||||
assert not execute_solid(double_even, input_values={"num": 3}, raise_on_error=False).success | assert not execute_solid( | ||||
double_even, input_values={"num": 3}, raise_on_error=False | |||||
).success | |||||
def test_basic_even_type_with_annotations(): | def test_basic_even_type_with_annotations(): | ||||
from docs_snippets.concepts.types.types import double_even_with_annotations | from docs_snippets.concepts.types.types import ( | ||||
double_even_with_annotations, | |||||
) | |||||
assert execute_solid(double_even_with_annotations, input_values={"num": 2}).success | assert execute_solid( | ||||
double_even_with_annotations, input_values={"num": 2} | |||||
).success | |||||
with pytest.raises(DagsterTypeCheckDidNotPass): | with pytest.raises(DagsterTypeCheckDidNotPass): | ||||
execute_solid(double_even_with_annotations, input_values={"num": 3}) | execute_solid(double_even_with_annotations, input_values={"num": 3}) | ||||
assert not execute_solid( | assert not execute_solid( | ||||
double_even_with_annotations, input_values={"num": 3}, raise_on_error=False | double_even_with_annotations, | ||||
input_values={"num": 3}, | |||||
raise_on_error=False, | |||||
).success | ).success | ||||
def test_python_object_dagster_type(): | def test_python_object_dagster_type(): | ||||
from docs_snippets.concepts.types.object_type import EvenType, double_even | from docs_snippets.concepts.types.object_type import EvenType, double_even | ||||
assert execute_solid(double_even, input_values={"even_num": EvenType(2)}).success | assert execute_solid( | ||||
double_even, input_values={"even_num": EvenType(2)} | |||||
).success | |||||
with pytest.raises(AssertionError): | with pytest.raises(AssertionError): | ||||
execute_solid(double_even, input_values={"even_num": EvenType(3)}) | execute_solid(double_even, input_values={"even_num": EvenType(3)}) | ||||
def test_usable_as_dagster_type(): | def test_usable_as_dagster_type(): | ||||
from docs_snippets.concepts.types.usable_as import EvenType, double_even | from docs_snippets.concepts.types.usable_as import EvenType, double_even | ||||
assert execute_solid(double_even, input_values={"even_num": EvenType(2)}).success | assert execute_solid( | ||||
double_even, input_values={"even_num": EvenType(2)} | |||||
).success | |||||
def test_make_python_type_usable_as_dagster_type(): | def test_make_python_type_usable_as_dagster_type(): | ||||
from docs_snippets.concepts.types.make_usable import EvenType, double_even | from docs_snippets.concepts.types.make_usable import EvenType, double_even | ||||
assert execute_solid(double_even, input_values={"even_num": EvenType(2)}).success | assert execute_solid( | ||||
double_even, input_values={"even_num": EvenType(2)} | |||||
).success | |||||
def test_unit_test(): | def test_unit_test(): | ||||
test_dagster_type() | test_dagster_type() |