Switch the demo catalog and copy to an electronics store

The shop sells tech, not clothing, so the demo data and page copy now
match that:

- seven categories: smartphones, laptops, tablets, audio, TVs, home
  appliances, accessories
- fifteen products with real-looking specs (screen, CPU, RAM, storage,
  energy class, warranty) instead of apparel attributes
- hero copy and meta description talk about tech and appliances
- banner updated in place by position/sort_order, so re-seeding does not
  leave a stale duplicate

Catalog polish:
- brand list and price range now follow the selected category instead of
  the whole catalog

Tests: storefront fixtures renamed to the tech domain; suite is 61
passing.
This commit is contained in:
apuc committed 2026-11-22 22:46:56 +03:00
1 parent 37d5d7b366
commit a64d567cff
5 files changed
+326 -144

No files matched your search

+39 -35
View File
@@ -28,31 +28,32 @@ class StorefrontHelperTests(TestCase):
class StorefrontPagesTests(TestCase):
@classmethod
def setUpTestData(cls):
cls.outer = Category.objects.create(
external_id="t-outer", name="Верхняя одежда", slug="verhnyaya-odezhda"
cls.laptops = Category.objects.create(
external_id="t-laptops", name="Ноутбуки", slug="noutbuki"
)
cls.knit = Category.objects.create(
external_id="t-knit", name="Трикотаж", slug="trikotazh"
cls.phones = Category.objects.create(
external_id="t-phones", name="Смартфоны", slug="smartfony"
)
cls.coat = Product.objects.create(
external_id="t-coat",
cls.laptop = Product.objects.create(
external_id="t-laptop",
sku="T-1",
name="Куртка тестовая",
slug="kurtka-testovaya",
category=cls.outer,
name="Ноутбук тестовый",
slug="noutbuk-testovyy",
category=cls.laptops,
brand="WorkPro",
price=Decimal("12000.00"),
old_price=Decimal("15000.00"),
stock=5,
is_hit=True,
attributes={"Цвет": "Чёрный"},
attributes={"Экран": '14" IPS', "ОЗУ": "16 ГБ"},
)
cls.tshirt = Product.objects.create(
external_id="t-tshirt",
cls.phone = Product.objects.create(
external_id="t-phone",
sku="T-2",
name="Футболка тестовая",
slug="futbolka-testovaya",
category=cls.knit,
brand="HOMM",
name="Смартфон тестовый",
slug="smartfon-testovyy",
category=cls.phones,
brand="Aurora",
price=Decimal("2500.00"),
stock=0,
is_new=True,
@@ -64,8 +65,8 @@ class StorefrontPagesTests(TestCase):
def test_home_shows_hits_and_new(self):
response = self.client.get("/")
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Куртка тестовая")
self.assertContains(response, "Футболка тестовая")
self.assertContains(response, "Ноутбук тестовый")
self.assertContains(response, "Смартфон тестовый")
def test_catalog_lists_only_active_products(self):
hidden = Product.objects.create(
@@ -78,43 +79,46 @@ class StorefrontPagesTests(TestCase):
)
response = self.client.get("/catalog/")
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Куртка тестовая")
self.assertContains(response, "Ноутбук тестовый")
self.assertNotContains(response, hidden.name)
def test_catalog_filters_by_category(self):
response = self.client.get("/catalog/?category=trikotazh")
self.assertContains(response, "Футболка тестовая")
self.assertNotContains(response, "Куртка тестовая")
response = self.client.get("/catalog/?category=smartfony")
self.assertContains(response, "Смартфон тестовый")
self.assertNotContains(response, "Ноутбук тестовый")
def test_catalog_filters_by_price_and_stock(self):
response = self.client.get("/catalog/?price_max=5000&in_stock=1")
self.assertNotContains(response, "Куртка тестовая")
self.assertNotContains(response, "Футболка тестовая")
self.assertNotContains(response, "Ноутбук тестовый")
self.assertNotContains(response, "Смартфон тестовый")
response = self.client.get("/catalog/?price_min=10000")
self.assertContains(response, "Куртка тестовая")
self.assertContains(response, "Ноутбук тестовый")
def test_catalog_search(self):
response = self.client.get("/catalog/", {"search": "куртка"})
self.assertContains(response, "Куртка тестовая")
self.assertNotContains(response, "Футболка тестовая")
response = self.client.get("/catalog/", {"search": "ноутбук"})
self.assertContains(response, "Ноутбук тестовый")
self.assertNotContains(response, "Смартфон тестовый")
def test_catalog_shows_filter_chips(self):
response = self.client.get("/catalog/?brand=HOMM&in_stock=1")
self.assertContains(response, "Бренд: HOMM")
response = self.client.get("/catalog/?brand=Aurora&in_stock=1")
self.assertContains(response, "Бренд: Aurora")
self.assertContains(response, "Только в наличии")
def test_catalog_ordering(self):
response = self.client.get("/catalog/?ordering=price")
content = response.content.decode()
self.assertLess(content.index("Футболка тестовая"), content.index("Куртка тестовая"))
self.assertLess(
content.index("Смартфон тестовый"), content.index("Ноутбук тестовый")
)
def test_product_page(self):
response = self.client.get("/catalog/kurtka-testovaya/")
response = self.client.get("/catalog/noutbuk-testovyy/")
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Куртка тестовая")
self.assertContains(response, "Цвет")
self.assertContains(response, "Чёрный")
self.assertContains(response, "Ноутбук тестовый")
self.assertContains(response, "Экран")
self.assertContains(response, "IPS")
self.assertContains(response, "16 ГБ")
def test_product_page_404(self):
self.assertEqual(self.client.get("/catalog/no-such-product/").status_code, 404)