Skip to content

Commit f38f695

Browse files
committed
fix(test): implement setup_pydantic_validated_model abstract methods in BasicProvider
1 parent f84e254 commit f38f695

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

‎tests/providers/basic.py‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515
TypeTestModel as TypeTestModelBase, ValidatedUser as ValidatedUserBase,
1616
TypeAdapterTest as TypeAdapterTestBase, YesOrNoBooleanAdapter,
1717
MappedUser as MappedUserBase, MappedPost as MappedPostBase, MappedComment as MappedCommentBase,
18-
ColumnMappingModel as ColumnMappingModelBase, MixedAnnotationModel as MixedAnnotationModelBase
18+
ColumnMappingModel as ColumnMappingModelBase, MixedAnnotationModel as MixedAnnotationModelBase,
19+
PydanticValidatedModel as PydanticValidatedModelBase,
1920
)
2021
from rhosocial.activerecord.testsuite.feature.basic.fixtures.models import (
2122
AsyncUser as AsyncUserBase, AsyncTypeCase as AsyncTypeCaseBase,
2223
AsyncValidatedUser as AsyncValidatedUserBase, AsyncValidatedFieldUser as AsyncValidatedFieldUserBase,
2324
AsyncTypeTestModel as AsyncTypeTestModelBase, AsyncTypeAdapterTest as AsyncTypeAdapterTestBase,
2425
AsyncMappedUser as AsyncMappedUserBase, AsyncMappedPost as AsyncMappedPostBase,
2526
AsyncMappedComment as AsyncMappedCommentBase,
26-
AsyncColumnMappingModel as AsyncColumnMappingModelBase, AsyncMixedAnnotationModel as AsyncMixedAnnotationModelBase
27+
AsyncColumnMappingModel as AsyncColumnMappingModelBase, AsyncMixedAnnotationModel as AsyncMixedAnnotationModelBase,
28+
AsyncPydanticValidatedModel as AsyncPydanticValidatedModelBase,
2729
)
2830
from rhosocial.activerecord.testsuite.feature.basic.fixtures.models import (
2931
BulkUser as BulkUserBase, AsyncBulkUser as AsyncBulkUserBase
@@ -143,6 +145,8 @@ def _select_model_class(base_cls, py312_cls, py311_cls, py310_cls, model_name: s
143145
AsyncMixedAnnotationModel = _select_model_class(AsyncMixedAnnotationModelBase, AsyncMixedAnnotationModel312, AsyncMixedAnnotationModel311, AsyncMixedAnnotationModel310, "AsyncMixedAnnotationModel")
144146
BulkUser = BulkUserBase
145147
AsyncBulkUser = AsyncBulkUserBase
148+
PydanticValidatedModel = PydanticValidatedModelBase
149+
AsyncPydanticValidatedModel = AsyncPydanticValidatedModelBase
146150

147151
from rhosocial.activerecord.testsuite.feature.basic.interfaces import IBasicProvider
148152
from rhosocial.activerecord.testsuite.core.protocols import WorkerTestProtocol
@@ -360,6 +364,12 @@ async def setup_async_type_adapter_model_and_schema(self, scenario_name: Optiona
360364
scenario_name = self.get_test_scenarios()[0] if self.get_test_scenarios() else "default"
361365
return await self._setup_async_model(AsyncTypeAdapterTest, scenario_name, "type_adapter_tests")
362366

367+
def setup_pydantic_validated_model(self, scenario_name: str) -> Type[ActiveRecord]:
368+
return self._setup_model(PydanticValidatedModel, scenario_name, "pydantic_validated_models")
369+
370+
async def setup_async_pydantic_validated_model(self, scenario_name: str) -> Type[ActiveRecord]:
371+
return await self._setup_async_model(AsyncPydanticValidatedModel, scenario_name, "pydantic_validated_models")
372+
363373
def setup_bulk_user_model(self, scenario_name: str) -> Type[ActiveRecord]:
364374
"""Sets up the database for the `BulkUser` model tests."""
365375
return self._setup_model(BulkUser, scenario_name, "bulk_users")
@@ -382,7 +392,8 @@ def cleanup_after_test(self, scenario_name: str):
382392
tables_to_drop = [
383393
'comments', 'posts', 'users', 'type_cases', 'type_tests',
384394
'validated_field_users', 'validated_users', 'type_adapter_tests',
385-
'column_mapping_items', 'mixed_annotation_items', 'bulk_users'
395+
'column_mapping_items', 'mixed_annotation_items', 'bulk_users',
396+
'pydantic_validated_models'
386397
]
387398
for backend_instance in self._active_backends:
388399
try:
@@ -404,7 +415,8 @@ async def cleanup_after_test_async(self, scenario_name: str):
404415
tables_to_drop = [
405416
'comments', 'posts', 'users', 'type_cases', 'type_tests',
406417
'validated_field_users', 'validated_users', 'type_adapter_tests',
407-
'column_mapping_items', 'mixed_annotation_items', 'bulk_users'
418+
'column_mapping_items', 'mixed_annotation_items', 'bulk_users',
419+
'pydantic_validated_models'
408420
]
409421
for backend_instance in self._active_async_backends:
410422
try:
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE TABLE [pydantic_validated_models] (
2+
[id] INT IDENTITY(1,1) PRIMARY KEY,
3+
[code] NVARCHAR(32),
4+
[quantity] INT,
5+
[step_count] INT,
6+
[price] DECIMAL(10, 2),
7+
[start_at] DATETIME2,
8+
[end_at] DATETIME2,
9+
[status] NVARCHAR(32),
10+
[normalized_name] NVARCHAR(50),
11+
[created_token] NVARCHAR(255)
12+
);

0 commit comments

Comments
 (0)