Exemplo n.º 1
0
def test_filter_available(dummy_room, create_reservation, create_blocking,
                          has_booking, has_blocking, has_pre_booking,
                          include_pre_bookings, has_pending_blocking,
                          include_pending_blockings, filtered):
    if has_booking:
        create_reservation(start_dt=datetime.combine(date.today(), time(8)),
                           end_dt=datetime.combine(date.today(), time(10)))
    if has_pre_booking:
        create_reservation(start_dt=datetime.combine(date.today(), time(10)),
                           end_dt=datetime.combine(date.today(), time(12)),
                           is_accepted=False)
    if has_blocking:
        create_blocking(state=BlockedRoom.State.accepted)
    if has_pending_blocking:
        create_blocking(state=BlockedRoom.State.pending)
    availabilty_filter = Room.filter_available(
        get_day_start(date.today()),
        get_day_end(date.today()), (RepeatFrequency.NEVER, 0),
        include_pre_bookings=include_pre_bookings,
        include_pending_blockings=include_pending_blockings)
    assert set(Room.find_all(availabilty_filter)) == (set() if filtered else
                                                      {dummy_room})
Exemplo n.º 2
0
 def _getAnswer(self):
     rooms = Room.find_all(Room.filter_available(self._start_dt, self._end_dt, self._repetition))
     return [room.id for room in rooms]