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
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