Skip to content

Commit

Permalink
(PC-33492)[API] feat: Added isOpenToPublic in VenurFactory and use th…
Browse files Browse the repository at this point in the history
…is attribut instead of isPermanent in post generation opening_hours
  • Loading branch information
pcharlet-pass committed Dec 10, 2024
1 parent 79e6037 commit 46b6439
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
3 changes: 2 additions & 1 deletion api/src/pcapi/core/offerers/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Meta:
)
isVirtual = False
isPermanent = factory.LazyAttribute(lambda o: o.venueTypeCode in models.PERMENANT_VENUE_TYPES)
isOpenToPublic = factory.LazyAttribute(lambda o: o.isPermanent is True)
venueTypeCode = models.VenueTypeCode.OTHER
description = factory.Faker("text", max_nb_chars=64)
audioDisabilityCompliant: bool | None = False
Expand Down Expand Up @@ -151,7 +152,7 @@ def opening_hours(
opening_hours = extracted
if not opening_hours:
opening_hours = []
if self.isPermanent:
if self.isOpenToPublic:
for weekday in models.Weekday:
if weekday.value == "MONDAY":
timespan = timespan_str_to_numrange([OPENING_HOURS[1]])
Expand Down
11 changes: 3 additions & 8 deletions api/tests/routes/pro/patch_venue_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,13 +700,11 @@ def test_when_siret_does_not_change(self, client) -> None:
assert response.status_code == 200
assert response.json["siret"] == venue.siret

def test_should_update_permanent_venue_opening_hours(self, client) -> None:
# given
def test_should_update_open_to_public_venue_opening_hours(self, client) -> None:
user_offerer = offerers_factories.UserOffererFactory()
venue = offerers_factories.VenueFactory(managingOfferer=user_offerer.offerer, isPermanent=True)
venue = offerers_factories.VenueFactory(managingOfferer=user_offerer.offerer, isOpenToPublic=True)

auth_request = client.with_session_auth(email=user_offerer.user.email)
# when
venue_data = populate_missing_data_from_venue(
{
"openingHours": [
Expand Down Expand Up @@ -743,15 +741,12 @@ def test_should_update_permanent_venue_opening_hours(self, client) -> None:
}

def test_should_not_update_opening_hours_when_response_is_none(self, client) -> None:
# given
user_offerer = offerers_factories.UserOffererFactory()
venue = offerers_factories.VenueFactory(managingOfferer=user_offerer.offerer, isPermanent=True)
venue = offerers_factories.VenueFactory(managingOfferer=user_offerer.offerer, isOpenToPublic=True)
auth_request = client.with_session_auth(email=user_offerer.user.email)

# when
venue_data = populate_missing_data_from_venue({"contact": None}, venue)

# then
response = auth_request.patch("/venues/%s" % venue.id, json=venue_data)
assert response.status_code == 200
assert len(venue.action_history) == 0
Expand Down

0 comments on commit 46b6439

Please sign in to comment.