예제 #1
0
 def _process_guest(self, raw_reservation, key_value_reservation,
                    tar_reservation: models.Reservation):
     guest_string = key_value_reservation.get('SUMMARY')
     if guest_string == 'Reserved':
         tar_reservation.guest = guest_string
         return True
     else:
         guest_search = re.search('Airbnb \\((.*)\\)', guest_string,
                                  re.IGNORECASE)
         if guest_search and guest_search.group(1) and guest_search.group(
                 1) not in self._not_available:
             tar_reservation.guest = guest_search.group(1)
             return True
     return False
def test_future_past_end_date():
  reservation = Reservation()
  for _ in range(100):
    f = FakeReservation(ReservationType.FUTURE_PAST)
    valid = Connection._process_end(f.raw_reservation, f.key_value_pair(), reservation)
    assert f._end + datetime.timedelta(days = 1) == reservation.end
    assert valid
def test_start_date_parse():
  reservation = Reservation()
  for _ in range(100):
    f = FakeReservation(ReservationType.PAST)
    valid = Connection._process_start(f.raw_reservation, f.key_value_pair(), reservation)
    assert f._start == reservation.start
    assert valid
예제 #4
0
def create_hotel():
    body = request.get_json()
    try:
        hotel = Reservation(**body).save()
        hotel_id = hotel.id
    except:
        return {'error': 'This reservation is already in database!'}
    return {'id': str(hotel_id)}, 200
예제 #5
0
 def _process_guest(self, raw_reservation, key_value_reservation,
                    tar_reservation: models.Reservation):
     guest_string = key_value_reservation.get('SUMMARY')
     if guest_string and guest_string not in self._not_available:
         guest_search = re.search('Reserved - (.*)', guest_string,
                                  re.IGNORECASE)
         guest_deconstruction = guest_string.split(" - ")
         if guest_search:
             tar_reservation.guest = guest_search.group(1)
             return True
         else:
             if guest_deconstruction[0] in self._not_available: return False
             raise ValueError(
                 "Guest not found in array or array is changed!")
     return False
예제 #6
0
 def _process_duration(self, tar_reservation:models.Reservation):
   tar_reservation.duration = int((tar_reservation.end - tar_reservation.start).days)
def test_past_end_date():
  reservation = Reservation()
  for _ in range(100):
    f = FakeReservation(ReservationType.PAST)
    valid = Connection._process_end(f.raw_reservation, f.key_value_pair(), reservation)
    assert not valid