aboutsummaryrefslogtreecommitdiff
path: root/tests/models/custom_types
diff options
context:
space:
mode:
authorMax Nanis2026-08-21 01:38:27 -0700
committerMax Nanis2026-08-21 01:38:27 -0700
commit05102628a7dc85a5a19a32415a7ec41ea7a91812 (patch)
treef5253ad2f57a9f05776eaf8f5dfb21bedbd08c7e /tests/models/custom_types
parent0c10237223829818752ab4fc431957c0b22a0e23 (diff)
downloadgeneralresearch-05102628a7dc85a5a19a32415a7ec41ea7a91812.tar.gz
generalresearch-05102628a7dc85a5a19a32415a7ec41ea7a91812.zip
moving create_dummy, organizing test_utils, working on django config for any repos
Diffstat (limited to 'tests/models/custom_types')
-rw-r--r--tests/models/custom_types/test_dsn.py9
-rw-r--r--tests/models/custom_types/test_uuid_str.py7
2 files changed, 9 insertions, 7 deletions
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