Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

(PC-1501): refactoring routes offers things events #500

Merged
merged 23 commits into from
Apr 9, 2019

Conversation

sofcalca
Copy link
Contributor

No description provided.

@sofcalca sofcalca force-pushed the PC-1501-refactoring-routes-offers-things-events branch from ddb37ef to 13215a4 Compare March 20, 2019 16:40
@annemarie35 annemarie35 self-requested a review March 21, 2019 14:45
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))
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

op.alter_column('offer', 'isNational', nullable=False)


def downgrade():
Copy link
Contributor

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 ?

Copy link
Contributor Author

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 ?

Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

assert thing.name == 'New Name'

@clean_database
def when_user_updating_thing_offer_is_not_linked_to_owningOfferers_offerers(self, app):
Copy link
Contributor

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 ?


class Returns400:
@clean_database
def when_trying_to_patch_forbidden_keys(self, app):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forbidden attributes plutôt ?

@@ -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):
Copy link
Contributor

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:
Copy link
Contributor

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

Copy link
Contributor Author

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 ?

Copy link
Contributor

@abel-andre abel-andre Mar 22, 2019

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)
Copy link
Contributor

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 ?

Copy link
Contributor Author

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@sofcalca sofcalca force-pushed the PC-1501-refactoring-routes-offers-things-events branch from 1270101 to dafcb22 Compare March 22, 2019 16:44
@sofcalca sofcalca force-pushed the PC-1501-refactoring-routes-offers-things-events branch from dafcb22 to b2afc03 Compare April 1, 2019 08:13
@Ledoux Ledoux changed the title Pc 1501 refactoring routes offers things events [WIP] (pC-1501) refactoring routes offers things events Apr 4, 2019
@Akhilian Akhilian force-pushed the PC-1501-refactoring-routes-offers-things-events branch from 4b7dfd9 to 8f1b487 Compare April 8, 2019 09:43
@Akhilian Akhilian force-pushed the PC-1501-refactoring-routes-offers-things-events branch from 8f1b487 to 06c1689 Compare April 8, 2019 09:44
@Akhilian Akhilian changed the title [WIP] (pC-1501) refactoring routes offers things events (PC-1501): refactoring routes offers things events Apr 8, 2019
@Ledoux Ledoux self-requested a review April 8, 2019 15:05
@Ledoux
Copy link
Contributor

Ledoux commented Apr 8, 2019

gros boulot, yes!

offer.conditions = event.conditions
offer.ageMin = event.ageMin
offer.ageMax = event.ageMax
offer.accessibility = event.accessibility
Copy link
Contributor Author

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),
Copy link
Contributor Author

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'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enlever la contrainte aussi

@sofcalca sofcalca merged commit a502b5c into master Apr 9, 2019
@sofcalca sofcalca deleted the PC-1501-refactoring-routes-offers-things-events branch April 9, 2019 08:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants