test_edge_file.py

tests/test_edge_file.py

THE LAST UNFIXED CAPABILITY ITEM IN THE NEGATIVE-GAP SET.

test_a_caller_row_names_its_file

None test_edge_file.test_a_caller_row_names_its_file(Path spread)

Each caller row names the file its caller lives in.

tests/test_edge_file.py:98

Show on the map →

Called by none

Calls dossier

Checks

  • assert files == {

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_a_caller_row_names_its_file → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance
REQ-DDB-QUERY-001measuredtest_a_caller_row_names_its_file → dossier → connect
REQ-DDB-QUERY-002measuredtest_a_caller_row_names_its_file → dossier → _chain_for → chain_trace
REQ-DDB-QUERY-003measuredtest_a_caller_row_names_its_file → dossier → identity_rowids
REQ-DDB-QUERY-004measured
REQ-DDB-QUERY-005inferredtest_a_caller_row_names_its_file → dossier → _chain_for → chain_trace → _make_node
REQ-DDB-QUERY-006measured
REQ-DDB-QUERY-009measured
REQ-DDB-QUERY-010measuredtest_a_caller_row_names_its_file → dossier → identity_rowids
REQ-DDB-QUERY-012measured
REQ-DDB-QUERY-013inferredtest_a_caller_row_names_its_file → dossier → _qualified_reread → _split_qualified → bare_tail
REQ-DDB-SCHEMA-011measured
REQ-DDB-WIKI-054inferredtest_a_caller_row_names_its_file → dossier → _rank_enum_over_mirror → _class_side_is_only_enum_mirrors → all
Source · 14 lines
def test_a_caller_row_names_its_file(spread: Path) -> None:
    """RED BEFORE THE FIX: `CallEdge` has no `file`, so counting the modules that consume a
    symbol costs one `dossier` per caller.
    """
    built = q.dossier(spread, "mbedtls_ct_memcmp")
    files = {c.name: c.file for c in built.function.callers}

    assert files == {
        "aes_crypt": "library/aes.c",
        "aes_verify": "library/aes.c",
        "rsa_check": "library/rsa.c",
    }, files

Activity · 3 steps
lines 102–102built = q.dossier(spread, "mbedtls_ct_memcmp")lines 103–103files = {c.name: c.file for c in built.function.callers}lines 105–109assert files == { "aes_crypt": "library/aes.c", "aes_verify": "library/aes.c", "rsa_check": "library/rsa.c", }, files

test_an_endpoint_with_no_resolvable_file_reports_empty

None test_edge_file.test_an_endpoint_with_no_resolvable_file_reports_empty(Path tmp_path)

An endpoint whose file is unknown says so by absence.

tests/test_edge_file.py:130

Show on the map →

Called by none

Calls dossier

Checks

  • assert [c.file for c in built.function.callers] == [""], ("an unresolvable file must be empty, never invented" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_an_endpoint_with_no_resolvable_file_reports_empty → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance
REQ-DDB-QUERY-001measuredtest_an_endpoint_with_no_resolvable_file_reports_empty → dossier → connect
REQ-DDB-QUERY-002measuredtest_an_endpoint_with_no_resolvable_file_reports_empty → dossier → _chain_for → chain_trace
REQ-DDB-QUERY-003measuredtest_an_endpoint_with_no_resolvable_file_reports_empty → dossier → identity_rowids
REQ-DDB-QUERY-004measured
REQ-DDB-QUERY-005inferredtest_an_endpoint_with_no_resolvable_file_reports_empty → dossier → _chain_for → chain_trace → _make_node
REQ-DDB-QUERY-006measured
REQ-DDB-QUERY-009measured
REQ-DDB-QUERY-010measuredtest_an_endpoint_with_no_resolvable_file_reports_empty → dossier → identity_rowids
REQ-DDB-QUERY-012measured
REQ-DDB-QUERY-013inferredtest_an_endpoint_with_no_resolvable_file_reports_empty → dossier → _qualified_reread → _split_qualified → bare_tail
REQ-DDB-SCHEMA-011measured
REQ-DDB-WIKI-054inferredtest_an_endpoint_with_no_resolvable_file_reports_empty → dossier → _rank_enum_over_mirror → _class_side_is_only_enum_mirrors → all
Source · 36 lines
def test_an_endpoint_with_no_resolvable_file_reports_empty(tmp_path: Path) -> None:
    """`''` AND NOT A GUESS. A caller row whose `file_id` resolves to no `path` row has no file to
    report, and inventing one would put a path nobody can open into a reply whose value is that
    its paths are real. The same rule `FileSubject.harvested` follows one module over.
    """
    db = tmp_path / "clew.db"
    conn = sqlite3.connect(str(db))
    conn.executescript(
        """
        CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT, type INTEGER);
        CREATE TABLE memberdef (
            rowid INTEGER PRIMARY KEY,
            kind TEXT, name TEXT, file_id INTEGER, bodyfile_id INTEGER,
            bodystart INTEGER, bodyend INTEGER, definition TEXT, argsstring TEXT,
            briefdescription TEXT, detaileddescription TEXT, static INTEGER
        );
        CREATE TABLE call_edges (
            caller_rowid INTEGER, callee_rowid INTEGER, source TEXT, confidence TEXT
        );
        """
    )
    conn.execute("INSERT INTO path (rowid, name, type) VALUES (1, 'library/ct.c', 1)")
    conn.executemany(
        "INSERT INTO memberdef (rowid, kind, name, file_id, bodyfile_id, bodystart, bodyend, "
        "definition, argsstring, briefdescription, detaileddescription, static) "
        "VALUES (?, 'function', ?, ?, ?, ?, ?, ?, '()', '', '', 0)",
        [(1, "callee", 1, 1, 10, 20, "int callee"), (2, "orphan", 99, 99, 30, 40, "int orphan")],
    )
    conn.execute("INSERT INTO call_edges VALUES (2, 1, 'doxygen_sqlite', 'exact')")
    conn.commit()
    conn.close()

    built = q.dossier(db, "callee")
    assert [c.file for c in built.function.callers] == [""], (
        "an unresolvable file must be empty, never invented"
    )

1 more lines, not shown

Activity · 10 steps
lines 135–135db = tmp_path / "clew.db"lines 136–136conn = sqlite3.connect(str(db))lines 137–150conn.executescript( """ CREATE TABLE path (rowid INTEGER PRIMARY KEY, name TEXT, type INTEGER); CREATE TABLE memberdef ( rowid INTEGER PRIMARY KEY, kind TEXT, name TEXT, file_id INTEGER, bodyfile_id INTEGER, bodystart INTEGER, bodyend INTEGER, definition TEXT, argsstring TEXT, briefdescription TEXT, detaileddescription TEXT, static INTEGER ); CREATE TABLE call_edges ( caller_rowid INTEGER, callee_rowid INTEGER, source TEXT, confidence TEXT ); """ )lines 151–151conn.execute("INSERT INTO path (rowid, name, type) VALUES (1, 'library/ct.c', 1)")lines 152–157conn.executemany( "INSERT INTO memberdef (rowid, kind, name, file_id, bodyfile_id, bodystart, bodyend, " "definition, argsstring, briefdescription, detaileddescription, static) " "VALUES (?, 'function', ?, ?, ?, ?, ?, ?, '()', '', '', 0)", [(1, "callee", 1, 1, 10, 20, "int callee"), (2, "orphan", 99, 99, 30, 40, "int orphan")], )lines 158–158conn.execute("INSERT INTO call_edges VALUES (2, 1, 'doxygen_sqlite', 'exact')")lines 159–159conn.commit()lines 160–160conn.close()lines 162–162built = q.dossier(db, "callee")lines 163–165assert [c.file for c in built.function.callers] == [""], ( "an unresolvable file must be empty, never invented" )

test_breadth_is_countable_without_a_second_call

None test_edge_file.test_breadth_is_countable_without_a_second_call(Path spread)

Breadth is countable from one reply.

tests/test_edge_file.py:114

Show on the map →

Called by none

Calls dossier

Checks

  • assert len(callers) == 3, "three callers"
  • assert len({c.file for c in callers}) == 2, ("two DISTINCT files — a caller count is not a module count" )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-INDEX-004measuredtest_breadth_is_countable_without_a_second_call → dossier → _chain_for → chain_trace → candidate_rows → symbol_provenance
REQ-DDB-QUERY-001measuredtest_breadth_is_countable_without_a_second_call → dossier → connect
REQ-DDB-QUERY-002measuredtest_breadth_is_countable_without_a_second_call → dossier → _chain_for → chain_trace
REQ-DDB-QUERY-003measuredtest_breadth_is_countable_without_a_second_call → dossier → identity_rowids
REQ-DDB-QUERY-004measured
REQ-DDB-QUERY-005inferredtest_breadth_is_countable_without_a_second_call → dossier → _chain_for → chain_trace → _make_node
REQ-DDB-QUERY-006measured
REQ-DDB-QUERY-009measured
REQ-DDB-QUERY-010measuredtest_breadth_is_countable_without_a_second_call → dossier → identity_rowids
REQ-DDB-QUERY-012measured
REQ-DDB-QUERY-013inferredtest_breadth_is_countable_without_a_second_call → dossier → _qualified_reread → _split_qualified → bare_tail
REQ-DDB-SCHEMA-011measured
REQ-DDB-WIKI-054inferredtest_breadth_is_countable_without_a_second_call → dossier → _rank_enum_over_mirror → _class_side_is_only_enum_mirrors → all
Source · 14 lines
def test_breadth_is_countable_without_a_second_call(spread: Path) -> None:
    """THE MARK IS ABOUT A MAGNITUDE — "on the order of twenty modules" — so what has to be
    cheap is the COUNT of distinct files, not the list of callers. Two callers in one file is one
    module, which is the case this fixture plants and the one a caller-count would get wrong.
    """
    built = q.dossier(spread, "mbedtls_ct_memcmp")
    callers = built.function.callers

    assert len(callers) == 3, "three callers"
    assert len({c.file for c in callers}) == 2, (
        "two DISTINCT files — a caller count is not a module count"
    )

Activity · 4 steps
lines 119–119built = q.dossier(spread, "mbedtls_ct_memcmp")lines 120–120callers = built.function.callerslines 122–122assert len(callers) == 3, "three callers"lines 123–125assert len({c.file for c in callers}) == 2, ( "two DISTINCT files — a caller count is not a module count" )