Skip to content

Commit

Permalink
added tests for pydantic.URL serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalik committed Dec 6, 2024
1 parent ab94a26 commit 092d4c7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest
from django.http import HttpResponse
from pydantic import BaseModel, ValidationError
from pydantic_core import Url

from ninja import Router
from ninja.responses import Response
Expand Down Expand Up @@ -172,3 +173,10 @@ def test_enum_encoding():
response = Response(data)
response_data = json.loads(response.content)
assert response_data["enum"] == str(data["enum"])


def test_pydantic_url():
data = {"url": Url("https://django-ninja.dev/")}
response = Response(data)
response_data = json.loads(response.content)
assert response_data == {"url": "https://django-ninja.dev/"}

0 comments on commit 092d4c7

Please sign in to comment.