From: Sebastián Ramírez Date: Sun, 28 Dec 2025 13:08:19 +0000 (-0800) Subject: ✅ Update tests, remove conditionals for Pydantic v1 (#1702) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8dbcd643d316da652026eaa2143f736184e8b071;p=thirdparty%2Ffastapi%2Fsqlmodel.git ✅ Update tests, remove conditionals for Pydantic v1 (#1702) --- diff --git a/tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py index ffbf7587..a766b37d 100644 --- a/tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py @@ -2,7 +2,6 @@ import importlib from types import ModuleType import pytest -from dirty_equals import IsDict from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -300,16 +299,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "HeroPublic": { @@ -319,16 +312,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, "id": {"title": "Id", "type": "integer"}, }, }, @@ -336,36 +323,18 @@ def test_tutorial(module: ModuleType): "title": "HeroUpdate", "type": "object", "properties": { - "name": IsDict( - { - "title": "Name", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Name", "type": "string"} - ), - "secret_name": IsDict( - { - "title": "Secret Name", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Secret Name", "type": "string"} - ), - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "name": { + "title": "Name", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, + "secret_name": { + "title": "Secret Name", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "ValidationError": { diff --git a/tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py index cbc722c5..241241a4 100644 --- a/tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py @@ -2,7 +2,6 @@ import importlib from types import ModuleType import pytest -from dirty_equals import IsDict from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -235,16 +234,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "HeroPublic": { @@ -254,16 +247,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, "id": {"title": "Id", "type": "integer"}, }, }, diff --git a/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial001.py index d70dce32..1690ba26 100644 --- a/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial001.py @@ -2,7 +2,6 @@ import importlib from types import ModuleType import pytest -from dirty_equals import IsDict from fastapi.testclient import TestClient from sqlalchemy import inspect from sqlalchemy.engine.reflection import Inspector @@ -159,16 +158,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "HeroPublic": { @@ -179,16 +172,10 @@ def test_tutorial(module: ModuleType): "id": {"title": "Id", "type": "integer"}, "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "ValidationError": { diff --git a/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial002.py b/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial002.py index 8d7c8064..b17fc20f 100644 --- a/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial002.py +++ b/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial002.py @@ -2,7 +2,6 @@ import importlib from types import ModuleType import pytest -from dirty_equals import IsDict from fastapi.testclient import TestClient from sqlalchemy import inspect from sqlalchemy.engine.reflection import Inspector @@ -159,16 +158,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "HeroPublic": { @@ -178,16 +171,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, "id": {"title": "Id", "type": "integer"}, }, }, diff --git a/tests/test_tutorial/test_fastapi/test_read_one/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_read_one/test_tutorial001.py index 7ebbecd8..420da4a3 100644 --- a/tests/test_tutorial/test_fastapi/test_read_one/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_read_one/test_tutorial001.py @@ -2,7 +2,6 @@ import importlib from types import ModuleType import pytest -from dirty_equals import IsDict from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -178,16 +177,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "HeroPublic": { @@ -197,16 +190,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, "id": {"title": "Id", "type": "integer"}, }, }, diff --git a/tests/test_tutorial/test_fastapi/test_relationships/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_relationships/test_tutorial001.py index cf24466c..07be8c30 100644 --- a/tests/test_tutorial/test_fastapi/test_relationships/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_relationships/test_tutorial001.py @@ -2,7 +2,6 @@ import importlib from types import ModuleType import pytest -from dirty_equals import IsDict from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -549,26 +548,14 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), - "team_id": IsDict( - { - "title": "Team Id", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Team Id", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, + "team_id": { + "title": "Team Id", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "HeroPublic": { @@ -578,26 +565,14 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), - "team_id": IsDict( - { - "title": "Team Id", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Team Id", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, + "team_id": { + "title": "Team Id", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, "id": {"title": "Id", "type": "integer"}, }, }, @@ -608,85 +583,43 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), - "team_id": IsDict( - { - "title": "Team Id", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Team Id", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, + "team_id": { + "title": "Team Id", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, "id": {"title": "Id", "type": "integer"}, - "team": IsDict( - { - "anyOf": [ - {"$ref": "#/components/schemas/TeamPublic"}, - {"type": "null"}, - ] - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"$ref": "#/components/schemas/TeamPublic"} - ), + "team": { + "anyOf": [ + {"$ref": "#/components/schemas/TeamPublic"}, + {"type": "null"}, + ] + }, }, }, "HeroUpdate": { "title": "HeroUpdate", "type": "object", "properties": { - "name": IsDict( - { - "title": "Name", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Name", "type": "string"} - ), - "secret_name": IsDict( - { - "title": "Secret Name", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Secret Name", "type": "string"} - ), - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), - "team_id": IsDict( - { - "title": "Team Id", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Team Id", "type": "integer"} - ), + "name": { + "title": "Name", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, + "secret_name": { + "title": "Secret Name", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, + "team_id": { + "title": "Team Id", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "TeamCreate": { @@ -728,36 +661,18 @@ def test_tutorial(module: ModuleType): "title": "TeamUpdate", "type": "object", "properties": { - "id": IsDict( - { - "title": "Id", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Id", "type": "integer"} - ), - "name": IsDict( - { - "title": "Name", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Name", "type": "string"} - ), - "headquarters": IsDict( - { - "title": "Headquarters", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Headquarters", "type": "string"} - ), + "id": { + "title": "Id", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, + "name": { + "title": "Name", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, + "headquarters": { + "title": "Headquarters", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, }, }, "ValidationError": { diff --git a/tests/test_tutorial/test_fastapi/test_response_model/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_response_model/test_tutorial001.py index 1ad004e9..2951268d 100644 --- a/tests/test_tutorial/test_fastapi/test_response_model/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_response_model/test_tutorial001.py @@ -2,7 +2,6 @@ import importlib from types import ModuleType import pytest -from dirty_equals import IsDict from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -131,28 +130,16 @@ def test_tutorial(module: ModuleType): "required": ["name", "secret_name"], "type": "object", "properties": { - "id": IsDict( - { - "title": "Id", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Id", "type": "integer"} - ), + "id": { + "title": "Id", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "ValidationError": { diff --git a/tests/test_tutorial/test_fastapi/test_session_with_dependency/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_session_with_dependency/test_tutorial001.py index 6e441ccc..6528f853 100644 --- a/tests/test_tutorial/test_fastapi/test_session_with_dependency/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_session_with_dependency/test_tutorial001.py @@ -2,7 +2,6 @@ import importlib from types import ModuleType import pytest -from dirty_equals import IsDict from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -302,16 +301,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "HeroPublic": { @@ -321,16 +314,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, "id": {"title": "Id", "type": "integer"}, }, }, @@ -338,36 +325,18 @@ def test_tutorial(module: ModuleType): "title": "HeroUpdate", "type": "object", "properties": { - "name": IsDict( - { - "title": "Name", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Name", "type": "string"} - ), - "secret_name": IsDict( - { - "title": "Secret Name", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Secret Name", "type": "string"} - ), - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "name": { + "title": "Name", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, + "secret_name": { + "title": "Secret Name", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "ValidationError": { diff --git a/tests/test_tutorial/test_fastapi/test_simple_hero_api/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_simple_hero_api/test_tutorial001.py index b803cee2..b6f88b13 100644 --- a/tests/test_tutorial/test_fastapi/test_simple_hero_api/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_simple_hero_api/test_tutorial001.py @@ -2,7 +2,6 @@ import importlib from types import ModuleType import pytest -from dirty_equals import IsDict from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -137,28 +136,16 @@ def test_tutorial(module: ModuleType): "required": ["name", "secret_name"], "type": "object", "properties": { - "id": IsDict( - { - "title": "Id", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Id", "type": "integer"} - ), + "id": { + "title": "Id", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "ValidationError": { diff --git a/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py index 3b028b7d..6982ee99 100644 --- a/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py @@ -2,7 +2,6 @@ import importlib from types import ModuleType import pytest -from dirty_equals import IsDict from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -534,26 +533,14 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), - "team_id": IsDict( - { - "title": "Team Id", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Team Id", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, + "team_id": { + "title": "Team Id", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "HeroPublic": { @@ -563,26 +550,14 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), - "team_id": IsDict( - { - "title": "Team Id", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Team Id", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, + "team_id": { + "title": "Team Id", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, "id": {"title": "Id", "type": "integer"}, }, }, @@ -590,46 +565,22 @@ def test_tutorial(module: ModuleType): "title": "HeroUpdate", "type": "object", "properties": { - "name": IsDict( - { - "title": "Name", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Name", "type": "string"} - ), - "secret_name": IsDict( - { - "title": "Secret Name", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Secret Name", "type": "string"} - ), - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), - "team_id": IsDict( - { - "title": "Team Id", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Team Id", "type": "integer"} - ), + "name": { + "title": "Name", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, + "secret_name": { + "title": "Secret Name", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, + "team_id": { + "title": "Team Id", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "TeamCreate": { @@ -655,26 +606,14 @@ def test_tutorial(module: ModuleType): "title": "TeamUpdate", "type": "object", "properties": { - "name": IsDict( - { - "title": "Name", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Name", "type": "string"} - ), - "headquarters": IsDict( - { - "title": "Headquarters", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Headquarters", "type": "string"} - ), + "name": { + "title": "Name", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, + "headquarters": { + "title": "Headquarters", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, }, }, "ValidationError": { diff --git a/tests/test_tutorial/test_fastapi/test_update/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_update/test_tutorial001.py index 9bc54fbc..cba5c1ae 100644 --- a/tests/test_tutorial/test_fastapi/test_update/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_update/test_tutorial001.py @@ -2,7 +2,6 @@ import importlib from types import ModuleType import pytest -from dirty_equals import IsDict from fastapi.testclient import TestClient from sqlmodel import create_engine from sqlmodel.pool import StaticPool @@ -279,16 +278,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "HeroPublic": { @@ -298,16 +291,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, "id": {"title": "Id", "type": "integer"}, }, }, @@ -315,36 +302,18 @@ def test_tutorial(module: ModuleType): "title": "HeroUpdate", "type": "object", "properties": { - "name": IsDict( - { - "title": "Name", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Name", "type": "string"} - ), - "secret_name": IsDict( - { - "title": "Secret Name", - "anyOf": [{"type": "string"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Secret Name", "type": "string"} - ), - "age": IsDict( - { - "title": "Age", - "anyOf": [{"type": "integer"}, {"type": "null"}], - } - ) - | IsDict( - # TODO: remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "name": { + "title": "Name", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, + "secret_name": { + "title": "Secret Name", + "anyOf": [{"type": "string"}, {"type": "null"}], + }, + "age": { + "title": "Age", + "anyOf": [{"type": "integer"}, {"type": "null"}], + }, }, }, "ValidationError": { diff --git a/tests/test_tutorial/test_fastapi/test_update/test_tutorial002.py b/tests/test_tutorial/test_fastapi/test_update/test_tutorial002.py index ede67fe4..22110ecb 100644 --- a/tests/test_tutorial/test_fastapi/test_update/test_tutorial002.py +++ b/tests/test_tutorial/test_fastapi/test_update/test_tutorial002.py @@ -2,7 +2,6 @@ import importlib from types import ModuleType import pytest -from dirty_equals import IsDict from fastapi.testclient import TestClient from sqlmodel import Session, create_engine from sqlmodel.pool import StaticPool @@ -342,16 +341,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "anyOf": [{"type": "integer"}, {"type": "null"}], - "title": "Age", - } - ) - | IsDict( - # TODO: Remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "anyOf": [{"type": "integer"}, {"type": "null"}], + "title": "Age", + }, "password": {"type": "string", "title": "Password"}, }, }, @@ -362,16 +355,10 @@ def test_tutorial(module: ModuleType): "properties": { "name": {"title": "Name", "type": "string"}, "secret_name": {"title": "Secret Name", "type": "string"}, - "age": IsDict( - { - "anyOf": [{"type": "integer"}, {"type": "null"}], - "title": "Age", - } - ) - | IsDict( - # TODO: Remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), + "age": { + "anyOf": [{"type": "integer"}, {"type": "null"}], + "title": "Age", + }, "id": {"title": "Id", "type": "integer"}, }, }, @@ -379,46 +366,22 @@ def test_tutorial(module: ModuleType): "title": "HeroUpdate", "type": "object", "properties": { - "name": IsDict( - { - "anyOf": [{"type": "string"}, {"type": "null"}], - "title": "Name", - } - ) - | IsDict( - # TODO: Remove when deprecating Pydantic v1 - {"title": "Name", "type": "string"} - ), - "secret_name": IsDict( - { - "anyOf": [{"type": "string"}, {"type": "null"}], - "title": "Secret Name", - } - ) - | IsDict( - # TODO: Remove when deprecating Pydantic v1 - {"title": "Secret Name", "type": "string"} - ), - "age": IsDict( - { - "anyOf": [{"type": "integer"}, {"type": "null"}], - "title": "Age", - } - ) - | IsDict( - # TODO: Remove when deprecating Pydantic v1 - {"title": "Age", "type": "integer"} - ), - "password": IsDict( - { - "anyOf": [{"type": "string"}, {"type": "null"}], - "title": "Password", - } - ) - | IsDict( - # TODO: Remove when deprecating Pydantic v1 - {"title": "Password", "type": "string"} - ), + "name": { + "anyOf": [{"type": "string"}, {"type": "null"}], + "title": "Name", + }, + "secret_name": { + "anyOf": [{"type": "string"}, {"type": "null"}], + "title": "Secret Name", + }, + "age": { + "anyOf": [{"type": "integer"}, {"type": "null"}], + "title": "Age", + }, + "password": { + "anyOf": [{"type": "string"}, {"type": "null"}], + "title": "Password", + }, }, }, "ValidationError": {