@@ -126,6 +126,46 @@ _FORM_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
</soap:Body>
|
||||
</soap:Envelope>"""
|
||||
|
||||
_CALC_RESPONSE_WITH_ADDITIONAL_SERVICE_FIRST = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
|
||||
<soap:Body>
|
||||
<m:CalcResponse xmlns:m="http://www.cargo3.ru">
|
||||
<m:return>
|
||||
<m:Key>Calc</m:Key>
|
||||
<m:List>
|
||||
<m:Key>Destination</m:Key>
|
||||
<m:List>
|
||||
<m:Key>Tariff</m:Key>
|
||||
<m:Value>additional-service-guid</m:Value>
|
||||
<m:Fields><m:Key>Total</m:Key><m:Value>100.00</m:Value></m:Fields>
|
||||
<m:Fields><m:Key>CurrencyName</m:Key><m:Value>RUR</m:Value></m:Fields>
|
||||
<m:Fields>
|
||||
<m:Key>Service</m:Key><m:Value>Доп. услуга</m:Value>
|
||||
</m:Fields>
|
||||
<m:Fields><m:Key>Urgency</m:Key><m:Value>urg-exp</m:Value></m:Fields>
|
||||
<m:Fields>
|
||||
<m:Key>AdditionalService</m:Key><m:Value>true</m:Value>
|
||||
</m:Fields>
|
||||
</m:List>
|
||||
<m:List>
|
||||
<m:Key>Tariff</m:Key>
|
||||
<m:Value>delivery-guid</m:Value>
|
||||
<m:Fields><m:Key>Total</m:Key><m:Value>793.00</m:Value></m:Fields>
|
||||
<m:Fields><m:Key>CurrencyName</m:Key><m:Value>RUR</m:Value></m:Fields>
|
||||
<m:Fields><m:Key>Service</m:Key><m:Value>Экспресс</m:Value></m:Fields>
|
||||
<m:Fields><m:Key>Urgency</m:Key><m:Value>urg-exp</m:Value></m:Fields>
|
||||
<m:Fields>
|
||||
<m:Key>AdditionalService</m:Key><m:Value>false</m:Value>
|
||||
</m:Fields>
|
||||
<m:Fields><m:Key>MinPeriod</m:Key><m:Value>1</m:Value></m:Fields>
|
||||
<m:Fields><m:Key>MaxPeriod</m:Key><m:Value>2</m:Value></m:Fields>
|
||||
</m:List>
|
||||
</m:List>
|
||||
</m:return>
|
||||
</m:CalcResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>"""
|
||||
|
||||
_ERROR_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
|
||||
<soap:Body>
|
||||
@@ -296,6 +336,50 @@ def test_provider_get_payment_price_selects_matching_tariff() -> None:
|
||||
assert price.price == Decimal("2000.00")
|
||||
|
||||
|
||||
def test_provider_get_payment_price_ignores_matching_additional_service() -> None:
|
||||
response = httpx.Response(200, text=_CALC_RESPONSE_WITH_ADDITIONAL_SERVICE_FIRST)
|
||||
client, _ = _build_client([response])
|
||||
provider = CSEProvider(client)
|
||||
request = make_init_payment_request(
|
||||
systemData={
|
||||
"tariff": {
|
||||
"provider": "cse",
|
||||
"serviceName": "Экспресс",
|
||||
"price": 79300,
|
||||
"deliveryDaysMin": 1,
|
||||
"deliveryDaysMax": 2,
|
||||
"tariffCode": "ДоставкаДоДверей|urg-exp",
|
||||
},
|
||||
"parcelType": "parcel",
|
||||
"weight": "1.0",
|
||||
"dimensions": {"length": "10", "width": "10", "height": "10"},
|
||||
}
|
||||
)
|
||||
|
||||
price = asyncio.run(provider.get_payment_price(request))
|
||||
|
||||
assert price is not None
|
||||
assert price.tariff_code == "ДоставкаДоДверей|urg-exp"
|
||||
assert price.price == Decimal("793.00")
|
||||
|
||||
|
||||
def test_provider_get_prices_excludes_additional_service_tariffs() -> None:
|
||||
client, _ = _build_client(
|
||||
[
|
||||
httpx.Response(200, text=_DELIVERY_TYPES_RESPONSE),
|
||||
httpx.Response(200, text=_CALC_RESPONSE_WITH_ADDITIONAL_SERVICE_FIRST),
|
||||
]
|
||||
)
|
||||
provider = CSEProvider(client)
|
||||
|
||||
prices = asyncio.run(provider.get_prices(_calc_request()))
|
||||
|
||||
assert [price.price for price in prices] == [Decimal("793.00")]
|
||||
assert [price.service_name for price in prices] == [
|
||||
"Экспресс — Дверь-Дверь"
|
||||
]
|
||||
|
||||
|
||||
def test_provider_register_order_returns_document_number() -> None:
|
||||
response = httpx.Response(200, text=_SAVE_RESPONSE)
|
||||
client, http_client = _build_client([response])
|
||||
|
||||
Reference in New Issue
Block a user