Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🗃️(api) make num_pdl field less provider-specific #233

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to
- Upgrade pyjwt to `2.10.0`
- Upgrade setuptools to `75.5.0`
- Send DB query details on Statique API errors only in debug mode
- Move `num_pdl` field to a 64-chars string

## [0.14.0] - 2024-11-15

Expand Down
2 changes: 1 addition & 1 deletion src/api/qualicharge/models/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class Statique(ModelSchemaMixin, BaseModel):
restriction_gabarit: str
station_deux_roues: bool
raccordement: Optional[RaccordementEnum]
num_pdl: Optional[Annotated[str, Field(pattern=r"^\d{14}$")]]
num_pdl: Optional[Annotated[str, Field(max_length=64)]]
date_mise_en_service: Optional[PastDate]
observations: Optional[str]
date_maj: PastDate
Expand Down
2 changes: 1 addition & 1 deletion src/api/qualicharge/schemas/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class Station(BaseTimestampedSQLModel, table=True):
horaires: str = Field(regex=r"(.*?)((\d{1,2}:\d{2})-(\d{1,2}:\d{2})|24/7)")
station_deux_roues: bool
raccordement: Optional[RaccordementEnum]
num_pdl: Optional[str] = Field(regex=r"^\d{14}$")
num_pdl: Optional[str] = Field(max_length=64)
date_maj: PastDate = Field(sa_type=Date)
date_mise_en_service: Optional[PastDate] = Field(sa_type=Date)

Expand Down
12 changes: 12 additions & 0 deletions src/api/tests/models/test_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,15 @@ def test_statique_model_afirev_previx_check():

# Default factory behavior should be consistent
StatiqueFactory.build()


def test_statique_model_num_pdl():
"""Test statique model accept various num_pdf patterns."""
statique = StatiqueFactory.build(num_pdl="0" * 14)
assert statique.num_pdl == "0" * 14

statique = StatiqueFactory.build(num_pdl="66666/E2/0000001")
assert statique.num_pdl == "66666/E2/0000001"

with pytest.raises(ValueError, match="String should have at most 64 characters"):
StatiqueFactory.build(num_pdl="a" * 65)