-
Notifications
You must be signed in to change notification settings - Fork 7
(PC-1501): refactoring routes offers things events #500
(PC-1501): refactoring routes offers things events #500
Conversation
ddb37ef
to
13215a4
Compare
op.add_column('offer', sa.Column('conditions', sa.String(120), nullable=True)) | ||
op.add_column('offer', sa.Column('ageMin', sa.Integer, nullable=True)) | ||
op.add_column('offer', sa.Column('ageMax', sa.Integer, nullable=True)) | ||
op.add_column('offer', sa.Column('accessibility', sa.Binary, nullable=True)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
je pense qu'on peut ne pas récupérer cette column qui est inutile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
alembic/versions/5eeaa2f48327_copy_thing_and_event_attributes_to_offer.py
Outdated
Show resolved
Hide resolved
alembic/versions/5eeaa2f48327_copy_thing_and_event_attributes_to_offer.py
Outdated
Show resolved
Hide resolved
op.alter_column('offer', 'isNational', nullable=False) | ||
|
||
|
||
def downgrade(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besoin de drop la constraint check_duration_minutes_not_null_for_event ou non ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comme la colonne disparait, pour moi elle part seule, non ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aucune idée, je sais qu'on en avait discuté la dernière fois pendant le mob mais je me souviens plus de la conclusion :-(
@@ -0,0 +1,25 @@ | |||
"""add authorId to event and thing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attention à remplacer 'author_id' ici et dans le nom du fichier par owning_offerer_id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
tests/routes/patch_offer_test.py
Outdated
assert thing.name == 'New Name' | ||
|
||
@clean_database | ||
def when_user_updating_thing_offer_is_not_linked_to_owningOfferers_offerers(self, app): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo dans le nom du test ?
tests/routes/patch_offer_test.py
Outdated
|
||
class Returns400: | ||
@clean_database | ||
def when_trying_to_patch_forbidden_keys(self, app): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forbidden attributes plutôt ?
validation/offers.py
Outdated
@@ -20,3 +22,17 @@ def check_venue_exists_when_requested(venue, venue_id): | |||
"Ce lieu n'a pas été trouvé" | |||
) | |||
raise errors | |||
|
|||
|
|||
def check_valid_edition(response: Request, thing_or_event_dict: dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attention, ce n'est pas une response mais une request !
|
||
@pytest.mark.standalone | ||
class Post: | ||
class Returns400: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je pense que certains de ces cas d'erreurs sont testés plus bas dans le code au niveau de Offer.errors(), donc est-ce qu'il faut tous les tester ici ? Comment choisir lesquels on teste au niveau de la route ?
Si t'as un avis sur la question... je pense qu'on manque d'une règle explicite là dessus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
En fait au niveau des erreurs on teste le fait qu'on lève bien l'exception ApiErrors. Ensuite, il me semble important de tester que quand on a une ApiError, notre route renvoie bien une 400. L'idéal à mon avis serait d'avoir un test qui dit "quand on a un ApiError, la route renvoie 400", mais on ne peut pas (encore) mocker la réponse des checks 😢
Une autre option c'est de ne garder qu'un cas d'erreur 400 pour être sûrs que cette exception est bien traitée dans les error handlers. Qu'en penses-tu ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Une autre option c'est de ne garder qu'un cas d'erreur 400 pour être sûrs que cette exception est bien traitée dans les error handlers
Je vote pour ça ! C'est l'approche qu'on avait eu la semaine dernière avec Anthony sur une autre PR
event = Event.query.filter_by(id=event_id).first() | ||
assert event.durationMinutes == 60 | ||
assert event.name == 'La pièce de théâtre' | ||
assert offer.type == str(EventType.SPECTACLE_VIVANT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ça fait beaucoup d'assertions d'un coup dans tout ces tests. Possible de découper ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ce qui me gêne de découper c'est que :
- ça fait tourner plus de tests de route, qui sont les plus longs
- dans le cas d'usage "doc API" ça pollue un peu
Mais c'est vrai que pour la lecture des tests c'est plus facile.
Tu en penses quoi ?
if self.venue: | ||
venue = self.venue | ||
else: | ||
venue = Venue.query.get(self.venueId) | ||
if thing and thing.url and not venue.isVirtual: | ||
if self.isDigital and not venue.isVirtual: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
1270101
to
dafcb22
Compare
dafcb22
to
b2afc03
Compare
4b7dfd9
to
8f1b487
Compare
… change in table constraints
8f1b487
to
06c1689
Compare
gros boulot, yes! |
domain/create_offer.py
Outdated
offer.conditions = event.conditions | ||
offer.ageMin = event.ageMin | ||
offer.ageMax = event.ageMax | ||
offer.accessibility = event.accessibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
à enlever : on voulait enlever cet attribut. Il n'est pas dans la migration d'ailleurs
models/offer.py
Outdated
ageMax = Column(Integer, | ||
nullable=True) | ||
|
||
accessibility = Column(Binary(1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il est encore là, il faut le supprimer !
models/offer.py
Outdated
|
||
accessibility = Column(Binary(1), | ||
CheckConstraint('("eventId" IS NULL) OR (accessibility IS NOT NULL)', | ||
name='check_accessibility_not_null_for_event'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enlever la contrainte aussi
No description provided.