feat: Dockerize and complete project
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
|
||||
from apps.pages.models import DownloadItem, FAQEntry
|
||||
|
||||
|
||||
class HomeViewTest(TestCase):
|
||||
def test_home_returns_200(self):
|
||||
response = self.client.get(reverse("pages:home"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_home_uses_correct_template(self):
|
||||
response = self.client.get(reverse("pages:home"))
|
||||
self.assertTemplateUsed(response, "pages/home.html")
|
||||
|
||||
|
||||
class AboutViewTest(TestCase):
|
||||
def test_about_returns_200(self):
|
||||
response = self.client.get(reverse("pages:about"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_about_uses_correct_template(self):
|
||||
response = self.client.get(reverse("pages:about"))
|
||||
self.assertTemplateUsed(response, "pages/about.html")
|
||||
|
||||
|
||||
class DownloadsViewTest(TestCase):
|
||||
def setUp(self):
|
||||
DownloadItem.objects.create(
|
||||
name="ViSERA Desktop",
|
||||
platform="windows",
|
||||
version="1.0",
|
||||
download_url="https://example.com/windows",
|
||||
is_active=True,
|
||||
)
|
||||
DownloadItem.objects.create(
|
||||
name="ViSERA Desktop",
|
||||
platform="macos",
|
||||
version="Coming Soon",
|
||||
download_url="#",
|
||||
is_active=False,
|
||||
)
|
||||
|
||||
def test_downloads_returns_200(self):
|
||||
response = self.client.get(reverse("pages:downloads"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_downloads_uses_correct_template(self):
|
||||
response = self.client.get(reverse("pages:downloads"))
|
||||
self.assertTemplateUsed(response, "pages/downloads.html")
|
||||
|
||||
def test_downloads_context_has_platform_keys(self):
|
||||
response = self.client.get(reverse("pages:downloads"))
|
||||
self.assertIn("windows_items", response.context)
|
||||
self.assertIn("macos_items", response.context)
|
||||
self.assertIn("linux_items", response.context)
|
||||
|
||||
def test_windows_item_in_context(self):
|
||||
response = self.client.get(reverse("pages:downloads"))
|
||||
self.assertEqual(response.context["windows_items"].count(), 1)
|
||||
|
||||
|
||||
class FAQViewTest(TestCase):
|
||||
def setUp(self):
|
||||
FAQEntry.objects.create(
|
||||
question="What is the license?",
|
||||
answer="It is CC BY-NC-SA.",
|
||||
order=1,
|
||||
is_active=True,
|
||||
)
|
||||
FAQEntry.objects.create(
|
||||
question="Hidden question",
|
||||
answer="Hidden answer",
|
||||
order=2,
|
||||
is_active=False,
|
||||
)
|
||||
|
||||
def test_faq_returns_200(self):
|
||||
response = self.client.get(reverse("pages:faq"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_faq_uses_correct_template(self):
|
||||
response = self.client.get(reverse("pages:faq"))
|
||||
self.assertTemplateUsed(response, "pages/faq.html")
|
||||
|
||||
def test_faq_only_shows_active_entries(self):
|
||||
response = self.client.get(reverse("pages:faq"))
|
||||
entries = response.context["faq_entries"]
|
||||
self.assertEqual(entries.count(), 1)
|
||||
self.assertEqual(entries.first().question, "What is the license?")
|
||||
|
||||
|
||||
class ContactViewTest(TestCase):
|
||||
def test_contact_returns_200(self):
|
||||
response = self.client.get(reverse("pages:contact"))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_contact_uses_correct_template(self):
|
||||
response = self.client.get(reverse("pages:contact"))
|
||||
self.assertTemplateUsed(response, "pages/contact.html")
|
||||
|
||||
|
||||
class NavigationContextTest(TestCase):
|
||||
def test_nav_main_products_in_context_on_all_pages(self):
|
||||
urls = [
|
||||
reverse("pages:home"),
|
||||
reverse("pages:about"),
|
||||
reverse("pages:faq"),
|
||||
reverse("pages:contact"),
|
||||
reverse("pages:downloads"),
|
||||
]
|
||||
for url in urls:
|
||||
response = self.client.get(url)
|
||||
self.assertIn("nav_main_products", response.context, f"Missing nav_main_products at {url}")
|
||||
Reference in New Issue
Block a user