Files
lux_fiscal/backend/app/services/crm/stub_client.py
lauadminandClaude Opus 5.5 2b7a92645a
CI / backend (pull_request) Successful in 3m7s
CI / frontend (pull_request) Failing after 15m55s
Add CRM stub flag, deploy/backup scripts, CI and prod runbook
- CRM_USE_STUB: local runs no longer reach the live CRM. With only the
  Checkbox stub, a stub receipt would still move the real order to PACKED.
  Refused in production, same as CHECKBOX_USE_STUB.
- scripts/deploy.sh: backup, fast-forward main, build, health check and
  code rollback on failure. scripts/backup.sh: pg_dump with verification
  and 14-day rotation (used by cron and deploy.sh).
- Gitea Actions CI: ruff + pytest, oxlint + build.
- DEPLOY.md runbook; CLAUDE.md rules for safe local development.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 20:52:20 +03:00

55 lines
1.8 KiB
Python

"""Фикстурный CRM-клиент: тесты и локальный запуск (`CRM_USE_STUB=true`) — не ходит в сеть."""
from __future__ import annotations
from app.schemas.orders import OrderOut
_FIXTURE_ORDERS: list[dict] = [
{
"ID": "100001",
"CreateDateTime": "2026-09-20 10:00:00",
"RecipientDName": "Тестовий Покупець",
"RecipientPhone": "+380501112233",
"RecipientEmail": None,
"Waybill_Number": "20450123456789",
"Notes": "Тестове замовлення",
"Total": {
"Cost": "0.00",
"Quantity": "2",
"Weight": "0",
"DiscountAmount": "0.00",
"DiscountPercent": "0.00",
"Amount": "1200.00",
},
"Goods": [
{
"ID": "1",
"SKU": "SKU-1",
"Name": "Товар 1",
"Price": "600.00",
"Quantity": "2.000",
"DiscountAmount": "0.00",
"DiscountPercent": "0.00",
"Amount": "1200.00",
}
],
}
]
class StubCrmClient:
def __init__(self, orders: list[dict] | None = None) -> None:
self._orders = orders if orders is not None else _FIXTURE_ORDERS
# order_id → статус, выставленный через set_status (для проверок в тестах).
self.statuses: dict[str, str] = {}
async def set_status(self, *, order_id: str, status: str) -> None:
self.statuses[order_id] = status
async def get_orders(self, *, status: str) -> list[OrderOut]:
return [
OrderOut.model_validate(order)
for order in self._orders
if order.get("Status", status) == status
]