Skip to content

Commit

Permalink
[IMP] resource_booking: Add test for resource.is_available() to span …
Browse files Browse the repository at this point in the history
…days

Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
  • Loading branch information
carmenbianca committed Feb 17, 2023
1 parent 11bc248 commit 61aca4f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions resource_booking/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,3 +844,33 @@ def test_resource_is_available(self):
utc.localize(datetime(2021, 3, 3, 11, 0)),
)
)

def test_resource_is_available_span_days(self):
# Correctly handle bookings that span across midnight.
cal_satsun = self.r_calendars[3]
rbc_satsun = self.rbcs[3]
resource = rbc_satsun.resource_ids[1]
self.rbt.resource_calendar_id = cal_satsun
self.env["resource.booking"].create(
{
"partner_id": self.partner.id,
"start": "2021-03-06 23:00:00",
"duration": 2,
"type_id": self.rbt.id,
"combination_id": rbc_satsun.id,
"combination_auto_assign": False,
}
)
self.assertFalse(
resource.is_available(
utc.localize(datetime(2021, 3, 6, 22, 0)),
utc.localize(datetime(2021, 3, 7, 2, 0)),
)
)
# Resource is available on the next weekend.
self.assertTrue(
resource.is_available(
utc.localize(datetime(2021, 3, 13, 22, 0)),
utc.localize(datetime(2021, 3, 14, 2, 0)),
)
)

0 comments on commit 61aca4f

Please sign in to comment.