Files
gomag-vending/api/app/constants.py
Claude Agent f6d283b743 refactor(status): introduce OrderStatus enum, replace string literals
Centralized order status values in api/app/constants.py via a
str-valued Enum so comparisons keep working. Replaced literals in:
- services: sync_service, sqlite_service, retry_service
- routers: sync, dashboard
- templates: dashboard.html, logs.html
- static JS: shared (ORDER_STATUS mirror), dashboard, logs
- tests: requirements, order_items_overwrite, business_rules

MALFORMED intentionally NOT added — introduced in follow-up PR2
(per-order failure isolation).

Full test suite: 231 unit + 33 e2e pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 08:45:32 +00:00

18 lines
601 B
Python

"""Application-wide constants shared across services, routers, and tests."""
from enum import Enum
class OrderStatus(str, Enum):
"""Order status values stored in SQLite `orders.status` column.
Inherits from `str` so existing string comparisons (==, in, dict.get)
keep working. Always use `.value` when passing to SQL queries or JSON
payloads to avoid Python-version-specific str(enum) surprises.
"""
IMPORTED = "IMPORTED"
ALREADY_IMPORTED = "ALREADY_IMPORTED"
SKIPPED = "SKIPPED"
ERROR = "ERROR"
CANCELLED = "CANCELLED"
DELETED_IN_ROA = "DELETED_IN_ROA"