From ffdb976f2c56d642f440f336a8f46be7b52eb5b1 Mon Sep 17 00:00:00 2001 From: Ushie Date: Sat, 19 Aug 2023 23:34:11 +0300 Subject: [PATCH] test: add info and donations tests --- api/models/info.py | 2 +- tests/test_donations.py | 15 +++++++++++++++ tests/test_info.py | 16 ++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/test_donations.py create mode 100644 tests/test_info.py diff --git a/api/models/info.py b/api/models/info.py index d1f3681..208b282 100644 --- a/api/models/info.py +++ b/api/models/info.py @@ -11,7 +11,7 @@ class InfoFields(BaseModel): name: str about: str contact: dict[str, str] - socials: SocialFields + socials: list[SocialFields] donations: DonationFields diff --git a/tests/test_donations.py b/tests/test_donations.py new file mode 100644 index 0000000..da56eb6 --- /dev/null +++ b/tests/test_donations.py @@ -0,0 +1,15 @@ +import pytest +from sanic import Sanic + +from api.models.donations import DonationsResponseModel + +from config import api_version + +# donations + + +@pytest.mark.asyncio +async def test_donations(app: Sanic): + _, response = await app.asgi_client.get(f"/{api_version}/donations") + assert response.status == 200 + assert DonationsResponseModel(**response.json) diff --git a/tests/test_info.py b/tests/test_info.py new file mode 100644 index 0000000..da540b2 --- /dev/null +++ b/tests/test_info.py @@ -0,0 +1,16 @@ +import pytest +from sanic import Sanic + +from api.models.info import InfoResponseModel + +from config import api_version + +# info + + +@pytest.mark.asyncio +async def test_info(app: Sanic): + _, response = await app.asgi_client.get(f"/{api_version}/info") + assert response.status == 200 + print(response.json) + assert InfoResponseModel(**response.json)