diff --git a/roulier/carriers/ciblex/schema.py b/roulier/carriers/ciblex/schema.py index ba2284f..9b04543 100644 --- a/roulier/carriers/ciblex/schema.py +++ b/roulier/carriers/ciblex/schema.py @@ -1,6 +1,7 @@ # Copyright 2024 Akretion (http://www.akretion.com). # @author Florian Mounier # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from pydantic import Field from ...helpers import prefix, suffix, none_as_empty, unaccent from ...schema import ( LabelInput, @@ -72,8 +73,10 @@ class CiblexAddress(Address): zip: str city: str country: str # FR ou MC, enum? - street3: str | None = None - street4: str | None = None + street1: str | None = Field(max_length=40, default=None) + street2: str | None = Field(max_length=40, default=None) + street3: str | None = Field(max_length=40, default=None) + street4: str | None = Field(max_length=40, default=None) def params(self): return { diff --git a/roulier/carriers/ciblex/tests/test_ciblex.py b/roulier/carriers/ciblex/tests/test_ciblex.py index a00991a..eec53f7 100644 --- a/roulier/carriers/ciblex/tests/test_ciblex.py +++ b/roulier/carriers/ciblex/tests/test_ciblex.py @@ -5,6 +5,7 @@ import pytest from datetime import date from roulier import roulier +from roulier.exception import InvalidApiInput from base64 import b64decode from ....helpers import merge from ....tests.helpers import assert_pdf @@ -88,3 +89,15 @@ def test_ciblex_label_epl(get_label_data): tracking = rv["parcels"][0]["tracking"] assert tracking["number"] assert tracking["url"].startswith("https://secure.extranet.ciblex.fr") + + +@pytest.mark.block_network +def test_ciblex_label_bad_street(get_label_data): + data = get_label_data + data["to_address"]["street1"] = "23 rue de la République 75001 Paris CEDEX 129832Z" + + with pytest.raises( + InvalidApiInput, + match="to_address.street1\n String should have at most 40 characters", + ): + roulier.get("ciblex", "get_label", data)