test_short_qualified.py

tests/test_short_qualified.py

A neighbour row's `qualified` is the SHORTEST separator-aligned suffix that is still unique.

test_a_callee_row_publishes_the_short_form_and_the_selector_follows_it

None test_short_qualified.test_a_callee_row_publishes_the_short_form_and_the_selector_follows_it(Path nested)

Short published identities each select exactly their own function.

tests/test_short_qualified.py:90

Checks

  • assert quals == ["alpha.Handler.run", "beta.Handler.run"]
  • assert identity_rowids(conn, edge.name, edge.qualified) == [
  • assert identity_rowids(conn, "run", "app.alpha.Handler.run") == [2]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_a_callee_row_publishes_the_short_form_and_the_selector_follows_it → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance
REQ-DDB-QUERY-001measuredtest_a_callee_row_publishes_the_short_form_and_the_selector_follows_it → dossier → connect
REQ-DDB-QUERY-002measuredtest_a_callee_row_publishes_the_short_form_and_the_selector_follows_it → dossier → _chain_for → chain_trace
REQ-DDB-QUERY-003measuredtest_a_callee_row_publishes_the_short_form_and_the_selector_follows_it → identity_rowids
REQ-DDB-QUERY-004measured
REQ-DDB-QUERY-005inferredtest_a_callee_row_publishes_the_short_form_and_the_selector_follows_it → dossier → _chain_for → chain_trace → _make_node
REQ-DDB-QUERY-006measured
REQ-DDB-QUERY-009measured
REQ-DDB-QUERY-010measuredtest_a_callee_row_publishes_the_short_form_and_the_selector_follows_it → identity_rowids
REQ-DDB-QUERY-012measured
REQ-DDB-QUERY-013inferredtest_a_callee_row_publishes_the_short_form_and_the_selector_follows_it → dossier → _qualified_reread → _split_qualified → bare_tail
REQ-DDB-SCHEMA-011measured
REQ-DDB-WIKI-054inferredtest_a_callee_row_publishes_the_short_form_and_the_selector_follows_it → dossier → _rank_enum_over_mirror → _class_side_is_only_enum_mirrors → all
Source · 22 lines
def test_a_callee_row_publishes_the_short_form_and_the_selector_follows_it(nested: Path) -> None:
    """THE ROUND TRIP, through `identity_rowids` — what `dossier(subject, qualified=...)` uses.

    @brief Short published identities each select exactly their own function.
    @return None.
    @version 1
    """
    built = q.dossier(nested, "main")
    quals = sorted(e.qualified for e in built.function.callees)
    assert quals == ["alpha.Handler.run", "beta.Handler.run"]
    conn = sqlite3.connect(str(nested))
    try:
        for edge in built.function.callees:
            assert identity_rowids(conn, edge.name, edge.qualified) == [
                2 if edge.qualified.startswith("alpha") else 3
            ]
        ## The FULL spelling still selects, so a consumer holding one keeps working.
        assert identity_rowids(conn, "run", "app.alpha.Handler.run") == [2]
    finally:
        conn.close()

Activity · 8 steps
lines 97–97built = q.dossier(nested, "main")lines 98–98quals = sorted(e.qualified for e in built.function.callees)lines 99–99assert quals == ["alpha.Handler.run", "beta.Handler.run"]lines 100–100conn = sqlite3.connect(str(nested))lines 101–101trylines 102–102◇ for edge in built.function.calleeslines 103–105assert identity_rowids(conn, edge.name, edge.qualified) == [ 2 if edge.qualified.startswith("alpha") else 3 ]lines 107–107assert identity_rowids(conn, "run", "app.alpha.Handler.run") == [2]

test_a_selector_in_the_other_languages_separator_still_selects

None test_short_qualified.test_a_selector_in_the_other_languages_separator_still_selects(Path nested)

`::` and `.` are interchangeable in a qualified selector.

tests/test_short_qualified.py:112

Checks

  • assert identity_rowids(conn, "run", "alpha::Handler::run") == [2]
  • assert identity_rowids(conn, "run", "app::beta::Handler::run") == [3]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-003measuredtest_a_selector_in_the_other_languages_separator_still_selects → identity_rowids
REQ-DDB-QUERY-010measuredtest_a_selector_in_the_other_languages_separator_still_selects → identity_rowids
Source · 15 lines
def test_a_selector_in_the_other_languages_separator_still_selects(nested: Path) -> None:
    """1.3.10. A mattermost agent passed `qualified="app::database::...::execute"` — C++ spelling
    for a TypeScript identity — and got `found: false` for a function the index holds. The two
    separators name the same nesting, so a selector written with either is resolved with both.

    @brief `::` and `.` are interchangeable in a qualified selector.
    @return None.
    @version 1
    """
    conn = sqlite3.connect(str(nested))
    try:
        assert identity_rowids(conn, "run", "alpha::Handler::run") == [2]
        assert identity_rowids(conn, "run", "app::beta::Handler::run") == [3]
    finally:
        conn.close()

1 more lines, not shown

Activity · 4 steps
lines 121–121conn = sqlite3.connect(str(nested))lines 122–122trylines 123–123assert identity_rowids(conn, "run", "alpha::Handler::run") == [2]lines 124–124assert identity_rowids(conn, "run", "app::beta::Handler::run") == [3]

test_the_shortest_unique_suffix

None test_short_qualified.test_the_shortest_unique_suffix(str full, set[str] others, str short)

short_qualified picks the shortest boundary-aligned unique suffix.

tests/test_short_qualified.py:43

Checks

  • assert short_qualified(full, others) == short

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-010measuredtest_the_shortest_unique_suffix → short_qualified
Source · 12 lines
def test_the_shortest_unique_suffix(full: str, others: set[str], short: str) -> None:
    """A QUALIFIED NAME KEEPS AT LEAST ITS OWNER: a bare name is what `name` already says, so the
    shortest form still carries one qualifier when the full name had one.

    @brief short_qualified picks the shortest boundary-aligned unique suffix.
    @return None.
    @version 1
    """
    assert short_qualified(full, others) == short


@pytest.fixture()