11from __future__ import annotations
22
33import inspect
4+ from collections import Counter
45from typing import Any
56
67import pytest
@@ -422,6 +423,20 @@ def _resolve_symbol_id_status_one(kuzu_graph) -> str:
422423 return sym_id
423424
424425
426+ def _resolve_symbol_short_name_status_many (kuzu_graph ) -> str :
427+ rows = kuzu_graph ._rows ( # noqa: SLF001
428+ "MATCH (s:Symbol) WHERE s.kind = 'method' RETURN s.name AS name" ,
429+ )
430+ counts = Counter (str (r ["name" ]) for r in rows if r .get ("name" ))
431+ dup_name = next ((name for name , c in counts .items () if c >= 2 ), None )
432+ if dup_name is None :
433+ pytest .fail ("no duplicated method short names in bank-chat fixture" )
434+ out = resolve_v2 (dup_name , hint_kind = "symbol" , graph = kuzu_graph )
435+ if not (out .success and out .status == "many" and len (out .candidates ) >= 2 ):
436+ pytest .fail (f"expected status many for short name { dup_name !r} , got { out .status !r} " )
437+ return dup_name
438+
439+
425440def _resolve_symbol_identifier_status_none (kuzu_graph ) -> str :
426441 ident = "com.nonexistent.ZzzMissing"
427442 out = resolve_v2 (ident , hint_kind = "symbol" , graph = kuzu_graph )
@@ -547,6 +562,19 @@ def test_hints_resolve_status_many_truncated_cap_wording() -> None:
547562 assert "10 candidates" in hints [0 ]
548563
549564
565+ def test_hints_resolve_success_false_suppresses () -> None :
566+ hints = generate_hints (
567+ "resolve" ,
568+ {
569+ "success" : False ,
570+ "status" : "none" ,
571+ "resolved_identifier" : "com.foo.Bar" ,
572+ "hint_kind" : "symbol" ,
573+ },
574+ )
575+ assert hints == []
576+
577+
550578def test_hints_resolve_payload_missing_identifier_suppressed () -> None :
551579 hints = generate_hints (
552580 "resolve" ,
@@ -573,6 +601,29 @@ def test_hints_resolve_v2_round_trip(kuzu_graph) -> None:
573601 assert wildcard_out .resolved_identifier == "com.foo.*Service"
574602 assert wildcard_out .hints == []
575603
604+ many_ident = _resolve_symbol_short_name_status_many (kuzu_graph )
605+ many_out = resolve_v2 (many_ident , hint_kind = "symbol" , graph = kuzu_graph )
606+ assert many_out .resolved_identifier == many_ident
607+ assert many_out .hints
608+ assert "candidates" in many_out .hints [0 ]
609+ assert "tighten identifier" in many_out .hints [0 ]
610+
611+ route_ident = "POST /v1/__no_such_resolve_route__"
612+ route_out = resolve_v2 (route_ident , hint_kind = "route" , graph = kuzu_graph )
613+ assert route_out .success is True
614+ assert route_out .status == "none"
615+ assert route_out .resolved_identifier == route_ident
616+ assert route_out .hints
617+ assert "find(kind='route'" in route_out .hints [0 ]
618+
619+ client_ident = "__no_such_resolve_client_target__"
620+ client_out = resolve_v2 (client_ident , hint_kind = "client" , graph = kuzu_graph )
621+ assert client_out .success is True
622+ assert client_out .status == "none"
623+ assert client_out .resolved_identifier == client_ident
624+ assert client_out .hints
625+ assert "find(kind='client'" in client_out .hints [0 ]
626+
576627 invalid_out = resolve_v2 ("" , graph = kuzu_graph )
577628 assert invalid_out .success is False
578629 assert invalid_out .resolved_identifier is None
0 commit comments