diff options
| author | Max Nanis | 2026-08-21 11:31:13 -0700 |
|---|---|---|
| committer | Max Nanis | 2026-08-21 11:31:13 -0700 |
| commit | ff538deb290c851364df85aa6ccc64bc3719ef64 (patch) | |
| tree | c04c3573ab6adab70971fef00d3420a5da5f9619 /tests/models/custom_types | |
| parent | 4fe0f6b5e0f0c744902e4c3ab8940e23a6f8a2e1 (diff) | |
| parent | c4a44873540ca4c0a3ab19b9beef4cfc6e0252a7 (diff) | |
| download | generalresearch-ff538deb290c851364df85aa6ccc64bc3719ef64.tar.gz generalresearch-ff538deb290c851364df85aa6ccc64bc3719ef64.zip | |
Merge branch 'master' into dev
Diffstat (limited to 'tests/models/custom_types')
| -rw-r--r-- | tests/models/custom_types/test_aware_datetime.py | 7 | ||||
| -rw-r--r-- | tests/models/custom_types/test_dsn.py | 9 | ||||
| -rw-r--r-- | tests/models/custom_types/test_uuid_str.py | 7 |
3 files changed, 13 insertions, 10 deletions
diff --git a/tests/models/custom_types/test_aware_datetime.py b/tests/models/custom_types/test_aware_datetime.py index a23413c..530142e 100644 --- a/tests/models/custom_types/test_aware_datetime.py +++ b/tests/models/custom_types/test_aware_datetime.py @@ -1,10 +1,11 @@ +from __future__ import annotations + import logging from datetime import datetime, timezone -from typing import Optional import pytest import pytz -from pydantic import BaseModel, ValidationError, Field +from pydantic import BaseModel, Field, ValidationError from generalresearch.models.custom_types import AwareDatetimeISO @@ -12,7 +13,7 @@ logger = logging.getLogger() class AwareDatetimeISOModel(BaseModel): - dt_optional: Optional[AwareDatetimeISO] = Field(default=None) + dt_optional: AwareDatetimeISO | None = Field(default=None) dt: AwareDatetimeISO diff --git a/tests/models/custom_types/test_dsn.py b/tests/models/custom_types/test_dsn.py index b37f2c4..16e1f83 100644 --- a/tests/models/custom_types/test_dsn.py +++ b/tests/models/custom_types/test_dsn.py @@ -2,13 +2,11 @@ from typing import Optional from uuid import uuid4 import pytest -from pydantic import BaseModel, ValidationError, Field -from pydantic import MySQLDsn +from pydantic import BaseModel, Field, MySQLDsn, ValidationError from pydantic_core import Url from generalresearch.models.custom_types import DaskDsn, SentryDsn - # --- Test Pydantic Models --- @@ -27,7 +25,7 @@ class TestDaskDsn: from dask.distributed import Client m = SettingsModel(dask="tcp://dask-scheduler.internal") - + assert isinstance(m.dask, Url) assert m.dask.scheme == "tcp" assert m.dask.host == "dask-scheduler.internal" assert m.dask.port == 8786 @@ -72,6 +70,7 @@ class TestDaskDsn: def test_port(self): m = SettingsModel(dask="tcp://dask-scheduler.internal") + assert isinstance(m.dask, Url) assert m.dask.port == 8786 @@ -81,6 +80,7 @@ class TestSentryDsn: sentry=f"https://{uuid4().hex}@12345.ingest.us.sentry.io/9876543" ) + assert isinstance(m.sentry, Url) assert m.sentry.scheme == "https" assert m.sentry.host == "12345.ingest.us.sentry.io" assert m.sentry.port == 443 @@ -109,4 +109,5 @@ class TestSentryDsn: def test_port(self): test_url: str = f"https://{uuid4().hex}@12345.ingest.us.sentry.io/9876543" m = SettingsModel(sentry=test_url) + assert isinstance(m.sentry, Url) assert m.sentry.port == 443 diff --git a/tests/models/custom_types/test_uuid_str.py b/tests/models/custom_types/test_uuid_str.py index 91af9ae..02e6a8b 100644 --- a/tests/models/custom_types/test_uuid_str.py +++ b/tests/models/custom_types/test_uuid_str.py @@ -1,14 +1,15 @@ -from typing import Optional +from __future__ import annotations + from uuid import uuid4 import pytest -from pydantic import BaseModel, ValidationError, Field +from pydantic import BaseModel, Field, ValidationError from generalresearch.models.custom_types import UUIDStr class UUIDStrModel(BaseModel): - uuid_optional: Optional[UUIDStr] = Field(default_factory=lambda: uuid4().hex) + uuid_optional: UUIDStr | None = Field(default_factory=lambda: uuid4().hex) uuid: UUIDStr |
