Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions tests/agent/test_collection_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ def test_every_collection_in_the_bundle_is_described_to_the_classifier() -> None


def test_the_userguide_prompt_alone_offers_no_collections() -> None:
message = build_classifier_message(frozenset({"userguide"}))
assert "disease_variants" not in message
# Both halves, in one test. Asserting only the absence passes when the
# collections block never renders for anyone -- verified by deleting it,
# after which this stayed green while a different test caught the fault.
# A guard that relies on a neighbour to be non-vacuous is one refactor
# away from guarding nothing.
assert "disease_variants" in build_classifier_message(
frozenset({"reactome", "userguide"})
), "the collections block does not render at all"
assert "disease_variants" not in build_classifier_message(frozenset({"userguide"}))


class _RecordingRag:
Expand Down Expand Up @@ -82,13 +89,25 @@ def test_the_userguide_is_never_narrowed_by_a_reactome_selection() -> None:
# collection; a leaked selection names collections it does not have, and
# `resolve_collections` would widen it back silently -- correct, but only
# by accident, and with a WARNING for every question.
#
# The reactome half is here on purpose. Asserting `None` alone passes
# against no implementation at all -- nothing set is also nothing seen --
# so this first shows the mechanism is live, then shows it does not reach
# the userguide. Verified by deleting the implementation: without the
# first half, this test stays green.
rag = _RecordingRag()
asyncio.run(
_builder(rag, "reactome").generate_answer(
_state("reactome", ["disease_variants"]), RunnableConfig()
)
)
assert rag.seen == [["disease_variants"]], "the mechanism is not live"
asyncio.run(
_builder(rag, "userguide").generate_answer(
_state("userguide", ["disease_variants"]), RunnableConfig()
)
)
assert rag.seen == [None], "a reactome selection leaked into the userguide"
assert rag.seen[1] is None, "a reactome selection leaked into the userguide"


def test_the_selection_does_not_outlive_the_question() -> None:
Expand All @@ -101,6 +120,9 @@ def test_the_selection_does_not_outlive_the_question() -> None:
_state("reactome", ["ewas"]), RunnableConfig()
)
)
# Set during, absent after. The second assertion alone would pass against
# no implementation, since nothing set is also nothing left behind.
assert rag.seen == [["ewas"]], "the mechanism is not live"
assert selected_collections.get() is None


Expand Down
Loading