Add Django backend, 1C integration, deploy config and API docs
Backend (Django 4.2 + DRF): - accounts: phone OTP login, JWT, profile, addresses - catalog: categories, products, images, filters, search, hits/new/related - orders: creation with Idempotency-Key, stock reservation, status history, cancel - loyalty: bonus accounts, promo codes, gift certificates - payments: payment records and YooKassa webhook handling - content: static pages, banners, site settings - integration: 1C exchange (catalog sync, order push via outbox, statuses, bonuses) - common: error envelope, pagination, request-id, integration auth, admin dashboard Infrastructure: Dockerfile, docker-compose (Postgres, Redis, Celery worker/beat, Nginx), requirements split by environment, OpenAPI contracts for site and 1C, architecture doc. Tests: 22 pytest cases covering catalog, orders, idempotency, OTP, integration.
This commit is contained in:
1 parent
5f8d37357d
commit
756f40353b
130 files changed
+10066
No files matched your search
@@ -0,0 +1,49 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from django.test import TestCase
|
||||
from rest_framework.test import APIClient
|
||||
|
||||
from .models import Category, Product
|
||||
|
||||
|
||||
class CatalogApiTests(TestCase):
|
||||
def setUp(self):
|
||||
self.client = APIClient()
|
||||
self.category = Category.objects.create(
|
||||
external_id="cat-1", name="Диваны", slug="divany"
|
||||
)
|
||||
self.product = Product.objects.create(
|
||||
external_id="prod-1",
|
||||
sku="SKU-1",
|
||||
name="Диван Осло",
|
||||
slug="divan-oslo",
|
||||
category=self.category,
|
||||
price=Decimal("49990.00"),
|
||||
stock=5,
|
||||
stock_status=Product.StockStatus.IN_STOCK,
|
||||
is_hit=True,
|
||||
is_new=True,
|
||||
)
|
||||
|
||||
def test_product_list(self):
|
||||
response = self.client.get("/api/v1/catalog/products/")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.data["count"], 1)
|
||||
self.assertEqual(response.data["results"][0]["sku"], "SKU-1")
|
||||
|
||||
def test_hits_endpoint(self):
|
||||
response = self.client.get("/api/v1/catalog/products/hits/")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.data["count"], 1)
|
||||
|
||||
def test_filter_by_price(self):
|
||||
response = self.client.get(
|
||||
"/api/v1/catalog/products/", {"price_min": "50000"}
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.data["count"], 0)
|
||||
|
||||
def test_product_detail(self):
|
||||
response = self.client.get("/api/v1/catalog/products/divan-oslo/")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.data["name"], "Диван Осло")
|
||||
Reference in new issue
Block a user