48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
from django.test import TestCase
|
|
from django.urls import reverse
|
|
|
|
from .models import Category, ContactInquiry, Product
|
|
|
|
|
|
class CatalogFlowTests(TestCase):
|
|
def setUp(self):
|
|
self.category = Category.objects.create(
|
|
name="Trauringe",
|
|
slug="trauringe",
|
|
description="Individuelle Ringe und Beratung.",
|
|
sort_order=1,
|
|
)
|
|
self.product = Product.objects.create(
|
|
category=self.category,
|
|
name="Signature Trauring",
|
|
slug="signature-trauring",
|
|
short_description="Ein klassischer Ring mit warmem Goldton.",
|
|
description="Ausgewählte Trauringe mit Gravuroption und persönlicher Beratung.",
|
|
material="Gold",
|
|
price_from="1290.00",
|
|
is_featured=True,
|
|
)
|
|
|
|
def test_homepage_uses_catalog_content(self):
|
|
response = self.client.get(reverse("home"))
|
|
self.assertContains(response, self.product.name)
|
|
self.assertContains(response, self.category.name)
|
|
|
|
def test_contact_form_creates_inquiry(self):
|
|
response = self.client.post(
|
|
reverse("contact"),
|
|
{
|
|
"product": self.product.pk,
|
|
"name": "Anna Becker",
|
|
"email": "anna@example.com",
|
|
"phone": "+49 123",
|
|
"preferred_contact_method": "phone",
|
|
"subject": "Beratung",
|
|
"message": "Ich möchte einen Termin für Trauringe.",
|
|
},
|
|
)
|
|
self.assertRedirects(response, reverse("contact_success"))
|
|
self.assertEqual(ContactInquiry.objects.count(), 1)
|
|
inquiry = ContactInquiry.objects.first()
|
|
self.assertEqual(inquiry.product, self.product)
|