Files
lux_fiscal/backend/tests/test_crm_checksum.py
lauadminandClaude Sonnet 5 f4072be451 Add CRM order queue: live sync, view modal, receipt tabs, delete
Wires the CRM (exoCRM GetOrders) into the dashboard as a locally
persisted order queue instead of the previous static mockup:

- CrmClient Protocol + ExoCrmClient/StubCrmClient for the CRM's
  signed JSON-RPC API
- Order model + migration, synced from CRM on each queue view;
  soft-deleted orders stay hidden across re-syncs
- GET/DELETE /api/v1/orders with "no receipt"/"receipt issued" tabs
  (the latter is empty until Checkbox fiscalization lands)
- Dashboard: real order list, item-detail modal, tab switcher,
  one-click delete

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 21:39:03 +03:00

29 lines
1.2 KiB
Python

"""Тесты контрольной суммы CRM-запросов. Без сети."""
from __future__ import annotations
import hashlib
from app.services.crm.checksum import compute_md5sum
class TestComputeMd5sum:
def test_matches_manual_calculation_for_flat_payload(self) -> None:
payload = {"b": "2", "a": "1"}
expected = hashlib.md5(b"12secret").hexdigest()
assert compute_md5sum(payload, "secret") == expected
def test_sorts_nested_keys_before_concatenating(self) -> None:
payload = {"params": {"z": "1", "a": "2"}, "apikey": "k"}
# sorted top-level: apikey, params -> "k" then sorted nested (a,z) -> "2","1"
expected = hashlib.md5(b"k21secret").hexdigest()
assert compute_md5sum(payload, "secret") == expected
def test_true_becomes_one_and_false_becomes_empty_string(self) -> None:
payload = {"a": True, "b": False}
expected = hashlib.md5(b"1secret").hexdigest()
assert compute_md5sum(payload, "secret") == expected
def test_different_payloads_give_different_sums(self) -> None:
assert compute_md5sum({"a": "1"}, "secret") != compute_md5sum({"a": "2"}, "secret")