Repository Public
1# =============================================================================2# SP BOUCHER | SOFTWARE & RESEARCH3# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4# =============================================================================5#6# PROJECT METADATA7# -----------------------------------------------------------------------------8# Project : Lou·Ka9# File : tests/test_quality.py10# Module : tests11# Repository : https://git.spboucher.ai/lou-ka12# Created : 2026-08-2113# Last Modified : 2026-08-2114#15# =============================================================================16# AUTHOR & PROFESSIONAL AFFILIATION17# =============================================================================18#19# Author : Simon-Pierre Boucher20# Position : Professor of Finance21# Institution : Université du Québec en Outaouais (UQO)22# Department : Département des sciences administratives23# Organization : SP Boucher24#25# Website : https://spboucher.ai26# Git : https://git.spboucher.ai27#28# =============================================================================29# OFFICIAL CONTACT DIRECTORY30# =============================================================================31#32# General : info@spboucher.ai33# Professional : contact@spboucher.ai34# Direct : simon@spboucher.ai35# Research : research@spboucher.ai36# Development : dev@spboucher.ai37# Support : support@spboucher.ai38# Security/Admin : admin@spboucher.ai39# Notifications : notifications@spboucher.ai40#41# Preferred Contact: contact@spboucher.ai42#43# =============================================================================44# COPYRIGHT & INTELLECTUAL PROPERTY45# =============================================================================46#47# Copyright (c) 202648# Simon-Pierre Boucher49#50# All rights reserved where applicable.51#52# This file is governed by the applicable project license,53# copyright notices, institutional agreements and relevant law.54#55# Unless expressly authorized by the applicable license or56# rights holder, copying, redistribution, sublicensing,57# publication and commercial exploitation are not permitted.58#59# Existing third-party rights and notices remain unaffected.60#61# =============================================================================62# CONFIDENTIALITY & SECURITY63# =============================================================================64#65# Classification : Public66# Distribution : Public repository; use is governed by the project license67# Security Contact : admin@spboucher.ai68#69# Access to this source does not independently grant permission70# to redistribute or disclose confidential materials.71#72# Do not embed credentials, private keys, access tokens,73# certificates or confidential personal information.74#75# =============================================================================76# LICENSE & MAINTENANCE77# =============================================================================78#79# License : None specified (no license file in this repository)80# Maintainer : Simon-Pierre Boucher81# Technical Contact: dev@spboucher.ai82#83# =============================================================================84# END OF SP BOUCHER SOURCE HEADER85# =============================================================================8687# -----------------------------------------------------------------------------88# Lou-Ka — tests de la porte de pertinence (quality.relevance_reason)89# Un stationnement/garage/local commercial à louer ne doit jamais être publié ;90# un logement qui INCLUT un stationnement doit rester publié.91# -----------------------------------------------------------------------------92from louka.quality import evaluate, relevance_reason939495def _reason(**kw):96 d = {"title": "", "description": "", "price": None, "unit_type": None,97 "bedrooms": None}98 d.update(kw)99 return relevance_reason(d)100101102# ---- hors sujet : doivent être mis en quarantaine ---------------------------103104def test_parking_titre():105 assert _reason(title="Parking à louer", price=200.0)106 assert _reason(title="Stationnement extérieur privé à louer – près du métro",107 price=100.0)108 assert _reason(title="Espace d'entreposage chauffé et éclairé", price=150.0)109110111def test_garage_description_titre_trompeur():112 # logisquebec : « Appartement Garage à Louer » à 195 $ = un garage113 assert _reason(114 title="Costebelle-Banville Appartement Garage à Louer Duberger",115 description="Grand garage/entrepôt de 8 pieds par 20 pieds, situé au "116 "cœur d'un quartier tranquille.",117 price=195.0, unit_type="3½")118119120def test_stationnement_titre_adresse():121 # titre-adresse, la description révèle la case de stationnement122 assert _reason(title="P158 1400 Boul Rene Levesque O",123 description="1 Stationnement intérieur #158 à vendre.",124 price=250.0)125126127def test_local_commercial():128 assert _reason(title="LOCAL COMMERCIAL À LOUER – CLÉ EN MAIN", price=3650.0)129 assert _reason(title="302 600 Rue Sherbrooke E",130 description="Espace de bureau lumineux et fonctionnel de "131 "290 pi², au centre-ville.", price=800.0)132133134def test_prix_de_case_sans_signal_logement():135 assert _reason(title="1288 Rue St-Antoine O. app. P3-151",136 description="Un dépot de $100 pour le ouvre garage.",137 price=280.0, unit_type="Condo")138139140def test_location_a_la_nuit():141 assert _reason(title="44, Perron O, Ste-Anne-Des-Monts à louer",142 description="Location court terme seulement. Tarif par nuit "143 "et non par mois.", price=210.0,144 unit_type="Maison")145146147# ---- logements légitimes : doivent rester publiés ---------------------------148149def test_logement_avec_stationnement_inclus():150 assert _reason(title="4½ NDG Stationnement + rangement inclus",151 price=1150.0, unit_type="4½") is None152 assert _reason(title="Grand 2 1/2 avec électros/internet/stationnement",153 price=995.0, unit_type="Studio") is None154155156def test_logement_titre_garage_prix_plausible():157 # vrai 4½ dont le titre vante le garage158 assert _reason(title="Garage Intérieur Chauffé",159 description="Magnifique logement 4 1/2, lumineux, doté d'un "160 "balcon, d'un ascenseur.",161 price=2250.0, unit_type="4½") is None162163164def test_immeuble_mixte_residentiel():165 assert _reason(title="4 Boulevard Cartier O., app. 717",166 description="Des résidences exquises et des espaces "167 "commerciaux au rez-de-chaussée.",168 price=2150.0, unit_type="4½") is None169170171def test_nom_de_rue_bureau():172 assert _reason(title="3220 Av Jacques Bureau",173 description="Magnifique logement de 2 chambres.",174 price=1200.0) is None175176177def test_chambre_pas_chere_reste_publiee():178 assert _reason(title="Grande Chambre ($600/mois), tout inclus + parking",179 price=600.0, unit_type="Chambre") is None180181182def test_evaluate_integre_la_pertinence():183 score, ok, reasons = evaluate({184 "title": "Parking à louer", "price": 200.0, "address": "123 rue X",185 "city": "Montréal", "description": "Belle place de stationnement " * 10,186 "images": ["a.jpg"], "url": "https://x"})187 assert not ok188 assert any("hors sujet" in r for r in reasons)189