Files
homm/backend/apps/accounts/tests.py
T
apuc 756f40353b 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.
2026-11-22 21:54:16 +03:00

35 lines
1.1 KiB
Python

from django.test import TestCase
from rest_framework.test import APIClient
class OtpAuthTests(TestCase):
def setUp(self):
self.client = APIClient()
def test_request_and_verify_otp(self):
response = self.client.post(
"/api/v1/auth/otp/request/",
{"phone": "+79991234567"},
format="json",
)
self.assertEqual(response.status_code, 200, response.data)
code = response.data["debug_code"]
response = self.client.post(
"/api/v1/auth/otp/verify/",
{"phone": "+79991234567", "code": code},
format="json",
)
self.assertEqual(response.status_code, 200, response.data)
self.assertIn("access", response.data)
self.assertIn("refresh", response.data)
self.assertEqual(response.data["user"]["phone"], "+79991234567")
def test_invalid_phone_is_rejected(self):
response = self.client.post(
"/api/v1/auth/otp/request/",
{"phone": "123"},
format="json",
)
self.assertEqual(response.status_code, 400)