Skip to content

Commit

Permalink
Add integration test for custom types
Browse files Browse the repository at this point in the history
  • Loading branch information
JensHeinrich authored and JensHeinrich committed Aug 11, 2023
1 parent 2c050a7 commit dfaae3e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/integration/cases/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .base_settings import cases as base_settings_cases
from .con_func import cases as con_func_cases
from .config_to_model import cases as config_to_model_cases
from .custom_types import cases as custom_types_cases
from .field import cases as generic_model_cases
from .folder_inside_folder import cases as folder_inside_folder_cases
from .is_base_model import cases as is_base_model_cases
Expand All @@ -28,6 +29,7 @@
*folder_inside_folder_cases,
*unicode_cases,
*con_func_cases,
*custom_types_cases,
]
before = Folder("project", *[case.source for case in cases])
expected = Folder("project", *[case.expected for case in cases])
59 changes: 59 additions & 0 deletions tests/integration/cases/custom_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from ..case import Case
from ..file import File

cases = [
Case(
name="Mark __get_validators__",
source=File(
"mark_get_validators.py",
content=[
"class SomeThing:",
" @classmethod",
" def __get_validators__(cls):",
" yield from []",
" return",
],
),
expected=File(
"mark_get_validators.py",
content=[
"class SomeThing:",
" @classmethod",
" # TODO[pydantic]: We couldn't refactor `__get_validators__`, please create the `__get_pydantic_core_schema__` manually.", # noqa: E501
" # Check https://docs.pydantic.dev/latest/migration/#defining-custom-types for more information.",
" def __get_validators__(cls):",
" yield from []",
" return",
],
),
),
Case(
name="Mark __modify_schema__",
source=File(
"mark_modify_schema.py",
content=[
"class SomeThing:",
" @classmethod",
" def __modify_schema__(",
" cls, field_schema: Dict[str, Any], field: Optional[ModelField]",
" ):",
" if field:",
" field_schema['example'] = \"Weird example\"",
],
),
expected=File(
"mark_modify_schema.py",
content=[
"class SomeThing:",
" @classmethod",
" # TODO[pydantic]: We couldn't refactor `__modify_schema__`, please create the `__get_pydantic_json_schema__` manually.", # noqa: E501
" # Check https://docs.pydantic.dev/latest/migration/#defining-custom-types for more information.",
" def __modify_schema__(",
" cls, field_schema: Dict[str, Any], field: Optional[ModelField]",
" ):",
" if field:",
" field_schema['example'] = \"Weird example\"",
],
),
),
]

0 comments on commit dfaae3e

Please sign in to comment.