Ejemplo n.º 1
0
def test_set_looking_for(tenant: Tenant, session: Session,
                         application: Application):
    assert not tenant.looking_for
    house_type = HouseType.BUNGALOW
    city = "preferred city"
    max_budget = 45.78
    application.set_looking_for(session, tenant, house_type, city, max_budget)
    assert tenant.looking_for
    assert tenant.looking_for.id
    assert tenant.looking_for.house_type == HouseType.BUNGALOW
    assert tenant.looking_for.city == city
    assert tenant.looking_for.max_budget == max_budget
Ejemplo n.º 2
0
def set_tenant_looking_for(
        data: LookingForSchema,
        tenant: Tenant = Depends(dependencies.get_current_tenant),
        app: Application = Depends(dependencies.get_application),
        session: Session = Depends(dependencies.get_database_session),
):
    try:
        return app.set_looking_for(session, tenant, data.house_type, data.city,
                                   data.max_budget)
    except ApplicationError as e:
        if "not found" in str(e).lower():
            raise HTTPException(404, str(e))
        raise HTTPException(400, str(e))