Skip to content

Commit

Permalink
[IMP] ciblex: Limit street fields to 40 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Jan 17, 2025
1 parent 7744ca6 commit aa43c5f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 5 additions & 2 deletions roulier/carriers/ciblex/schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2024 Akretion (http://www.akretion.com).
# @author Florian Mounier <florian.mounier@akretion.com>
# 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,
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions roulier/carriers/ciblex/tests/test_ciblex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit aa43c5f

Please sign in to comment.