Enhance type hinting
All checks were successful
Deploy to Server / deploy (push) Successful in 22s

This commit is contained in:
Joakim Hellsén 2026-04-05 03:57:18 +02:00
commit 06c0af7009
Signed by: Joakim Hellsén
SSH key fingerprint: SHA256:/9h/CsExpFp+PRhsfA0xznFx2CGfTT5R/kpuFfUgEQk
6 changed files with 100 additions and 49 deletions

View file

@ -1,3 +1,5 @@
from typing import TYPE_CHECKING
from django.test import RequestFactory
from django.test import TestCase
from django.test.utils import override_settings
@ -5,6 +7,9 @@ from django.urls import reverse
from core.views import _build_base_url
if TYPE_CHECKING:
from django.test.client import _MonkeyPatchedWSGIResponse
@override_settings(ALLOWED_HOSTS=["example.com"])
class TestBuildBaseUrl(TestCase):
@ -16,7 +21,7 @@ class TestBuildBaseUrl(TestCase):
def test_valid_base_url(self) -> None:
"""Test that the base URL is built correctly."""
base_url = _build_base_url()
base_url: str = _build_base_url()
assert base_url == "https://ttvdrops.lovinator.space"
@ -25,12 +30,16 @@ class TestSitemapViews(TestCase):
def test_sitemap_twitch_channels_view(self) -> None:
"""Test that the Twitch channels sitemap view returns a valid XML response."""
response = self.client.get(reverse("sitemap-twitch-channels"))
response: _MonkeyPatchedWSGIResponse = self.client.get(
reverse("sitemap-twitch-channels"),
)
assert response.status_code == 200
assert "<urlset" in response.content.decode()
def test_sitemap_twitch_drops_view(self) -> None:
"""Test that the Twitch drops sitemap view returns a valid XML response."""
response = self.client.get(reverse("sitemap-twitch-drops"))
response: _MonkeyPatchedWSGIResponse = self.client.get(
reverse("sitemap-twitch-drops"),
)
assert response.status_code == 200
assert "<urlset" in response.content.decode()