Ejemplo n.º 1
0
def test_tenant_reject_accepted_invitation_fail(
    application: Application,
    session: Session,
    tenant: Tenant,
    booking_request: BookingRequest,
):
    booking_req = application.accept_application_invitation(
        session, tenant, booking_request)
    with pytest.raises(ApplicationError):
        application.reject_application_invitation(session, tenant, booking_req)
Ejemplo n.º 2
0
def test_tenant_reject_invitation_to_apply_for_apartment(
    application: Application,
    session: Session,
    tenant: Tenant,
    booking_request: BookingRequest,
):
    application.reject_application_invitation(session, tenant, booking_request)
    booking_req = session.query(BookingRequest).get(booking_request.id)
    assert booking_req.status == BookingRequestStatus.REJECTED
    assert not booking_req.apartment_application_id
Ejemplo n.º 3
0
def rejct_invite(
        invitation_id: UUID,
        tenant: Tenant = Depends(deps.get_current_tenant),
        session: Session = Depends(deps.get_database_session),
        application: Application = Depends(deps.get_application),
):
    try:
        invitation = (session.query(BookingRequest).filter(
            BookingRequest.tenant_id == tenant.id).filter(
                BookingRequest.id == invitation_id).first())
        if not invitation:
            raise HTTPException(404, "Invite not found")
        return application.reject_application_invitation(
            session, tenant, invitation)
    except ApplicationError as e:
        raise HTTPException(400, str(e))
Ejemplo n.º 4
0
def test_tenant_accept_rejected_invitation_fail(
    client: TestClient,
    session: Session,
    booking_request: BookingRequest,
    application: Application,
    tenant: Tenant,
    tenant_auth_header: dict,
):
    rejected_invite = application.reject_application_invitation(
        session, tenant, booking_request
    )
    assert session.query(BookingRequest).count() == 1
    assert booking_request.status == BookingRequestStatus.REJECTED
    response = client.post(
        f"/api/invites/{rejected_invite.id}",
        headers=tenant_auth_header,
    )
    assert response.status_code == 400
    assert booking_request.status == BookingRequestStatus.REJECTED