This commit is contained in:
@@ -70,6 +70,62 @@ _SAVE_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
</soap:Body>
|
||||
</soap:Envelope>"""
|
||||
|
||||
_TRACKING_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
|
||||
<soap:Body>
|
||||
<m:TrackingResponse xmlns:m="http://www.cargo3.ru">
|
||||
<m:return>
|
||||
<m:Key>Tracking</m:Key>
|
||||
<m:List>
|
||||
<m:Key>CSE-000123</m:Key>
|
||||
<m:Value>Order</m:Value>
|
||||
<m:Properties><m:Key>Number</m:Key><m:Value>CSE-000123</m:Value></m:Properties>
|
||||
<m:List>
|
||||
<m:Key>Заказ принят, идет обработка заказа.</m:Key>
|
||||
<m:Properties>
|
||||
<m:Key>DateTime</m:Key><m:Value>2026-06-01T10:00:00</m:Value>
|
||||
</m:Properties>
|
||||
</m:List>
|
||||
<m:List>
|
||||
<m:Key>Накладная оформлена.</m:Key>
|
||||
<m:Properties>
|
||||
<m:Key>DateTime</m:Key><m:Value>2026-06-01T10:02:00</m:Value>
|
||||
</m:Properties>
|
||||
</m:List>
|
||||
<m:Tables>
|
||||
<m:Key>Waybills</m:Key>
|
||||
<m:List>
|
||||
<m:Key>496-AA-1676378</m:Key>
|
||||
<m:Properties>
|
||||
<m:Key>DocumentType</m:Key><m:Value>Waybill</m:Value>
|
||||
</m:Properties>
|
||||
<m:Properties>
|
||||
<m:Key>Number</m:Key><m:Value>496-AA-1676378</m:Value>
|
||||
</m:Properties>
|
||||
</m:List>
|
||||
</m:Tables>
|
||||
</m:List>
|
||||
</m:return>
|
||||
</m:TrackingResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>"""
|
||||
|
||||
_FORM_RESPONSE = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
|
||||
<soap:Body>
|
||||
<m:GetFormsForDocumentsResponse xmlns:m="http://www.cargo3.ru">
|
||||
<m:return>
|
||||
<m:Key>GetPrintForms</m:Key>
|
||||
<m:List>
|
||||
<m:Key>496-AA-1676378</m:Key>
|
||||
<m:Properties><m:Key>FormFormat</m:Key><m:Value>PDF</m:Value></m:Properties>
|
||||
<m:BData>JVBERg==</m:BData>
|
||||
</m:List>
|
||||
</m:return>
|
||||
</m:GetFormsForDocumentsResponse>
|
||||
</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>
|
||||
@@ -253,6 +309,40 @@ def test_provider_register_order_returns_document_number() -> None:
|
||||
assert http_client.calls[0]["url"] == "http://lk-test.cse.ru/1c/ws/web1c.1cws"
|
||||
|
||||
|
||||
def test_provider_get_order_extracts_waybill_number_from_tracking() -> None:
|
||||
response = httpx.Response(200, text=_TRACKING_RESPONSE)
|
||||
client, http_client = _build_client([response])
|
||||
provider = CSEProvider(client)
|
||||
|
||||
result = asyncio.run(provider.get_order("CSE-000123"))
|
||||
|
||||
assert result.order_number == "CSE-000123"
|
||||
assert result.status_code == "Накладная оформлена."
|
||||
assert result.waybill_number == "496-AA-1676378"
|
||||
content = http_client.calls[0]["content"].decode("utf-8")
|
||||
assert "Tracking" in content
|
||||
assert "DocumentType" in content
|
||||
assert "Order" in content
|
||||
|
||||
|
||||
def test_provider_download_waybill_pdf_uses_print_form() -> None:
|
||||
response = httpx.Response(200, text=_FORM_RESPONSE)
|
||||
client, http_client = _build_client([response])
|
||||
provider = CSEProvider(client)
|
||||
|
||||
pdf = asyncio.run(provider.download_waybill_pdf("496-AA-1676378"))
|
||||
|
||||
assert pdf == b"%PDF"
|
||||
content = http_client.calls[0]["content"].decode("utf-8")
|
||||
assert "GetFormsForDocuments" in content
|
||||
assert "DocumentType" in content
|
||||
assert "waybill" in content
|
||||
assert "Type" in content
|
||||
assert "print" in content
|
||||
assert "Format" in content
|
||||
assert "pdf" in content
|
||||
|
||||
|
||||
def test_save_order_request_uses_selected_tariff_urgency() -> None:
|
||||
request = make_init_payment_request(
|
||||
systemData={
|
||||
|
||||
Reference in New Issue
Block a user