Skip to content

Commit 1b57544

Browse files
committed
(BSR)[API] fix: fix educational institution institutionId field in factory
1 parent d8a2274 commit 1b57544

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

api/src/pcapi/core/educational/factories.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class EducationalInstitutionFactory(BaseFactory[models.EducationalInstitution]):
4141
class Meta:
4242
model = models.EducationalInstitution
4343

44-
institutionId = factory.Sequence(lambda x: f"{x + 1}470009E")
44+
institutionId = factory.Sequence(lambda x: _get_institution_id(x))
4545
name = factory.Sequence("DE LA TOUR{}".format)
4646
city = "PARIS"
4747
postalCode = "75000"
@@ -52,6 +52,13 @@ class Meta:
5252
longitude = 2.3522
5353

5454

55+
def _get_institution_id(sequence_number: int) -> str:
56+
# institutionId (UAI) is a unique string with 7 digits and 1 letter
57+
# put sequence number at the end and left-fill with 0
58+
prefix = (7 - len(str(sequence_number))) * "0"
59+
return f"{prefix}{sequence_number}F"
60+
61+
5562
class CollectiveOfferFactory(BaseFactory[models.CollectiveOffer]):
5663
class Meta:
5764
model = models.CollectiveOffer

0 commit comments

Comments
 (0)