Skip to content

Commit

Permalink
Extend test + additional control
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Aug 28, 2023
1 parent c57cc38 commit e8dec63
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
6 changes: 4 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Changelog
2.0.0rc2 (unreleased)
---------------------

- Fix slots overlap valiation on booking move
[folix-01]
- Show default gates as unavailable in get_gates method, if they are overrided.
[cekk]

Expand Down Expand Up @@ -90,8 +92,8 @@ Changelog
months-slots => available-slots
prenotazione-schema => booking-schema
@@download_reservation => @@download/bookings.xlsx
[cekk] [mamico]
[cekk] [mamico]


2.0.0.dev3 (2023-07-20)
-----------------------
Expand Down
10 changes: 5 additions & 5 deletions src/redturtle/prenotazioni/adapters/conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ def conflicts(self, data, exclude=None):
availability = self.add_exclude(exclude, availability)

# remove not interesting gates
# for key in set(availability.keys()):
# if key != data.get("gate", None):
# gate = data.get("gate", None)
# if gate and key != gate:
# del availability[key]
for key in set(availability.keys()):
if key != data.get("gate", None):
gate = data.get("gate", None)
if gate and key != gate:
del availability[key]

for gate_slots in six.itervalues(availability):
for gate_slot in gate_slots:
Expand Down
41 changes: 40 additions & 1 deletion src/redturtle/prenotazioni/tests/test_move_booking_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from plone.app.testing import TEST_USER_ID
from plone.restapi.testing import RelativeSession
from redturtle.prenotazioni.adapters.booker import IBooker
from redturtle.prenotazioni.testing import REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING
from redturtle.prenotazioni.testing import (
REDTURTLE_PRENOTAZIONI_API_FUNCTIONAL_TESTING,
)
import transaction
import unittest
import pytz
Expand Down Expand Up @@ -86,3 +88,40 @@ def test_move_booking(self):
datetime.fromisoformat(response.json()["booking_date"]),
tomorrow,
)

def test_move_booking_to_used_slot(self):
self.booker.book(
{
"booking_date": self.today,
"booking_type": "Type A",
"title": "foo",
},
force_gate="Gate A",
)
booking = self.booker.book(
{
"booking_date": self.today,
"booking_type": "Type A",
"title": "foo",
},
force_gate="Gate B",
)

uid = booking.UID()

transaction.commit()

response = self.api_session_admin.post(
f"{self.folder_prenotazioni.absolute_url()}/@booking-move",
json={
"booking_id": uid,
"booking_date": self.today.isoformat(),
"gate": "Gate A",
},
)

self.assertEquals(response.status_code, 400)
self.assertEquals(
response.json()["message"],
"Sorry, this slot is not available or does not fit your booking.",
)

0 comments on commit e8dec63

Please sign in to comment.