003 Add cdek

This commit is contained in:
Раис Юсупалиев
2026-03-07 14:57:16 +03:00
parent e0b6a3f7e6
commit 86dbd2bdd6
12 changed files with 794 additions and 16 deletions
@@ -0,0 +1,33 @@
from decimal import Decimal
import pytest
from app.adapters.delivery_providers.cdek.mapper import CDEKMappingError, map_cdek_response
def test_map_cdek_response_maps_first_tariff_to_unified_model() -> None:
payload = {
"tariff_codes": [
{
"tariff_name": "Express",
"delivery_sum": "1234.50",
"currency": "rub",
"period_min": 2,
"period_max": 4,
}
]
}
result = map_cdek_response(payload)
assert result.provider == "cdek"
assert result.service_name == "Express"
assert result.price == Decimal("1234.50")
assert result.currency == "RUB"
assert result.delivery_days_min == 2
assert result.delivery_days_max == 4
def test_map_cdek_response_raises_for_missing_tariff_codes() -> None:
with pytest.raises(CDEKMappingError):
map_cdek_response({"tariff_codes": []})