示例#1
0
def test_reject_booking_request(
    apartment: Apartment,
    session: Session,
    tenant: Tenant,
):
    booking_request = BookingRequest(tenant_id=tenant.id,
                                     apartment_id=apartment.id)
    booking_request.reject()
    session.add(booking_request)
    session.commit()
    assert booking_request.status == BookingRequestStatus.REJECTED
    assert not booking_request.apartment_application
示例#2
0
 def reject_application_invitation(
     self,
     session: Session,
     tenant: Tenant,
     booking_request: BookingRequest,
 ):
     if booking_request.tenant_id != tenant.id:
         raise ApplicationError("Request not for tenant")
     if booking_request.status == BookingRequestStatus.ACCEPTED:
         raise ApplicationError("Invitation has been accepted")
     booking_request.reject()
     session.commit()
     return booking_request
示例#3
0
 def accept_application_invitation(self, session: Session, tenant: Tenant,
                                   booking_request: BookingRequest):
     if booking_request.tenant_id != tenant.id:
         raise ApplicationError("Request not for tenant")
     if booking_request.status == BookingRequestStatus.REJECTED:
         raise ApplicationError("Invitation has been rejected")
     apartment_application = self.apartment_application_service.create(
         session,
         apartment=booking_request.apartment,
         tenant=booking_request.tenant,
         commit=False,
     )
     booking_request.accept(apartment_application)
     session.commit()
     return booking_request
示例#4
0
def test_accept_booking_request(
    apartment: Apartment,
    session: Session,
    tenant: Tenant,
    new_apartment_application: ApartmentApplication,
):
    booking_request = BookingRequest(tenant_id=tenant.id,
                                     apartment_id=apartment.id)
    session.add(booking_request)
    session.commit()
    assert booking_request.status == BookingRequestStatus.PENDING
    booking_request.accept(new_apartment_application)
    session.commit()
    assert booking_request.status == BookingRequestStatus.ACCEPTED
    assert booking_request.apartment_application == new_apartment_application
示例#5
0
def test_booking_request_relationships(
    apartment: Apartment,
    session: Session,
    tenant: Tenant,
):
    booking_request = BookingRequest(tenant_id=tenant.id,
                                     apartment_id=apartment.id)
    session.add(booking_request)
    session.commit()
    assert booking_request.status == BookingRequestStatus.PENDING