Support dans l'API et le MCP de l'opérateur startswith, utile pour les codes CPV
This commit is contained in:
@@ -39,6 +39,12 @@ def test_notcontains_filter():
|
||||
assert params == ["%x%"]
|
||||
|
||||
|
||||
def test_startswith_filter_uses_prefix_wildcard():
|
||||
where, params, _ = build_where([("objet__startswith", "72")], SCHEMA)
|
||||
assert where == '"objet" LIKE ?'
|
||||
assert params == ["72%"]
|
||||
|
||||
|
||||
def test_comparison_operators_on_int():
|
||||
where, params, _ = build_where([("annee__strictly_greater", "2023")], SCHEMA)
|
||||
assert where == '"annee" > ?'
|
||||
|
||||
@@ -34,6 +34,16 @@ def test_client_instructions_include_oauth_apps():
|
||||
assert any("ChatGPT" in t for t in titles)
|
||||
|
||||
|
||||
def test_prompt_tips_mentions_columns_and_examples():
|
||||
from src.app import app # noqa: F401
|
||||
from src.pages.compte.mcp import prompt_tips
|
||||
|
||||
text = str(prompt_tips())
|
||||
assert "Morbihan" in text # un exemple de prompt concret
|
||||
assert "colonnes" in text # l'astuce sur le choix des colonnes
|
||||
assert "lien" in text # mention du lien vers la fiche marché
|
||||
|
||||
|
||||
def _collect_titles(component):
|
||||
# Parcourt récursivement les AccordionItem pour collecter leurs `title`.
|
||||
found = []
|
||||
|
||||
@@ -117,6 +117,19 @@ def test_search_marches_cpv_filters_correctly():
|
||||
assert search_marches(cpv="999")["meta"]["total"] == 0
|
||||
|
||||
|
||||
def test_build_where_args_cpv_is_prefix():
|
||||
# le filtre nommé cpv est un « commence par » (code CPV hiérarchique)
|
||||
args = build_where_args({"cpv": "72"}, None)
|
||||
assert ("codeCPV__startswith", "72") in args
|
||||
|
||||
|
||||
def test_search_marches_cpv_is_prefix_not_contains():
|
||||
# "1600" est contenu dans le codeCPV de test (71600000) mais n'en est pas
|
||||
# le préfixe : en sémantique « commence par », aucun résultat.
|
||||
assert search_marches(cpv="1600")["meta"]["total"] == 0
|
||||
assert search_marches(cpv="716")["meta"]["total"] >= 1
|
||||
|
||||
|
||||
def test_search_marches_page_2_is_empty_with_correct_meta():
|
||||
result = search_marches(acheteur_id="123", page=2)
|
||||
assert result["meta"]["page"] == 2
|
||||
|
||||
Reference in New Issue
Block a user