test_not_indexed_report.py

tests/test_not_indexed_report.py

A miss names the file types it did not read, so an empty answer is not read as absence.

test_an_index_built_before_this_release_claims_nothing

None test_not_indexed_report.test_an_index_built_before_this_release_claims_nothing(Path tmp_path)

No row means an empty report and a zero count.

tests/test_not_indexed_report.py:156

Show on the map →

Called by none

Calls index_scope

Checks

  • assert scope.not_indexed == ()
  • assert scope.not_indexed_count == 0

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_an_index_built_before_this_release_claims_nothing → index_scope → connect
REQ-DDB-QUERY-003measuredtest_an_index_built_before_this_release_claims_nothing → index_scope → _indexed_paths → table_exists
REQ-DDB-QUERY-007measuredtest_an_index_built_before_this_release_claims_nothing → index_scope
Source · 22 lines
def test_an_index_built_before_this_release_claims_nothing(tmp_path: Path) -> None:
    """The row is absent, which must read as "not recorded" and never as "nothing was
    missed" — the same rule `IndexScope.source` follows for an index built before the
    provenance was stamped.

    @brief No row means an empty report and a zero count. @version 1
    """
    db = tmp_path / "clew.db"
    conn = sqlite3.connect(str(db))
    try:
        conn.execute("CREATE TABLE path (rowid INTEGER PRIMARY KEY, type INT, name TEXT)")
        conn.execute("INSERT INTO path (type, name) VALUES (1, 'src/main.c')")
        conn.commit()
    finally:
        conn.close()

    scope = index_scope(db)

    assert scope.not_indexed == ()
    assert scope.not_indexed_count == 0

Activity · 9 steps
lines 163–163db = tmp_path / "clew.db"lines 164–164conn = sqlite3.connect(str(db))lines 165–165trylines 166–166conn.execute("CREATE TABLE path (rowid INTEGER PRIMARY KEY, type INT, name TEXT)")lines 167–167conn.execute("INSERT INTO path (type, name) VALUES (1, 'src/main.c')")lines 168–168conn.commit()lines 172–172scope = index_scope(db)lines 174–174assert scope.not_indexed == ()lines 175–175assert scope.not_indexed_count == 0

test_an_unrecorded_report_is_absent_from_the_served_payload

None test_not_indexed_report.test_an_unrecorded_report_is_absent_from_the_served_payload()

No stamped report means no key in the reply.

tests/test_not_indexed_report.py:178

Checks

  • assert _scope_payload(stamped)["not_indexed"] == [".sh=3", ".yml=1"]
  • assert _scope_payload(stamped)["not_indexed_count"] == 4
  • assert "not_indexed" not in _scope_payload(unrecorded)
  • assert "not_indexed_count" not in _scope_payload(unrecorded)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_an_unrecorded_report_is_absent_from_the_served_payload → _scope_payload → one
Source · 21 lines
def test_an_unrecorded_report_is_absent_from_the_served_payload() -> None:
    """THE FALSY-DROP RULE ON THE SERVED SURFACE. An index built before this release has no
    row, and serving `not_indexed: []` beside it states that nothing was missed — which is
    the claim the build never made. `emptiness.py` puts it plainly: "the limit was not
    reached" and "nobody looked" must not read the same.

    So the keys are dropped entirely when the count is zero, and the caller distinguishes
    the two cases by presence, as it does for every other optional measurement here.

    @brief No stamped report means no key in the reply. @version 1
    """
    from clew.mcp_server.emptiness import _scope_payload
    from clew.query.models import IndexScope

    stamped = IndexScope("declared", "why", 12, ("src",), (".c",), (".sh=3", ".yml=1"), 4)
    unrecorded = IndexScope("declared", "why", 12, ("src",), (".c",))

    assert _scope_payload(stamped)["not_indexed"] == [".sh=3", ".yml=1"]
    assert _scope_payload(stamped)["not_indexed_count"] == 4
    assert "not_indexed" not in _scope_payload(unrecorded)
    assert "not_indexed_count" not in _scope_payload(unrecorded)

1 more lines, not shown

Activity · 8 steps
lines 189–189from clew.mcp_server.emptiness import _scope_payloadlines 190–190from clew.query.models import IndexScopelines 192–192stamped = IndexScope("declared", "why", 12, ("src",), (".c",), (".sh=3", ".yml=1"), 4)lines 193–193unrecorded = IndexScope("declared", "why", 12, ("src",), (".c",))lines 195–195assert _scope_payload(stamped)["not_indexed"] == [".sh=3", ".yml=1"]lines 196–196assert _scope_payload(stamped)["not_indexed_count"] == 4lines 197–197assert "not_indexed" not in _scope_payload(unrecorded)lines 198–198assert "not_indexed_count" not in _scope_payload(unrecorded)

test_the_query_layer_serves_what_the_build_stamped

None test_not_indexed_report.test_the_query_layer_serves_what_the_build_stamped(Path tmp_path)

`IndexScope.not_indexed` carries the stamped row.

tests/test_not_indexed_report.py:134

Show on the map →

Called by none

Calls index_scope

Checks

  • assert scope.not_indexed == (".sh=3", ".yml=1")
  • assert scope.not_indexed_count == 4

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_the_query_layer_serves_what_the_build_stamped → index_scope → connect
REQ-DDB-QUERY-003measuredtest_the_query_layer_serves_what_the_build_stamped → index_scope → _indexed_paths → table_exists
REQ-DDB-QUERY-007measuredtest_the_query_layer_serves_what_the_build_stamped → index_scope
Source · 22 lines
def test_the_query_layer_serves_what_the_build_stamped(tmp_path: Path) -> None:
    """@brief `IndexScope.not_indexed` carries the stamped row. @version 1"""
    db = tmp_path / "clew.db"
    conn = sqlite3.connect(str(db))
    try:
        conn.execute("CREATE TABLE path (rowid INTEGER PRIMARY KEY, type INT, name TEXT)")
        conn.execute("INSERT INTO path (type, name) VALUES (1, 'src/main.c')")
        conn.execute("CREATE TABLE build_meta (key TEXT PRIMARY KEY, value TEXT)")
        conn.executemany(
            "INSERT INTO build_meta (key, value) VALUES (?, ?)",
            [("scope.not_indexed", ".sh=3, .yml=1"), ("scope.not_indexed_count", "4")],
        )
        conn.commit()
    finally:
        conn.close()

    scope = index_scope(db)

    assert scope.not_indexed == (".sh=3", ".yml=1")
    assert scope.not_indexed_count == 4

Activity · 11 steps
lines 136–136db = tmp_path / "clew.db"lines 137–137conn = sqlite3.connect(str(db))lines 138–138trylines 139–139conn.execute("CREATE TABLE path (rowid INTEGER PRIMARY KEY, type INT, name TEXT)")lines 140–140conn.execute("INSERT INTO path (type, name) VALUES (1, 'src/main.c')")lines 141–141conn.execute("CREATE TABLE build_meta (key TEXT PRIMARY KEY, value TEXT)")lines 142–145conn.executemany( "INSERT INTO build_meta (key, value) VALUES (?, ?)", [("scope.not_indexed", ".sh=3, .yml=1"), ("scope.not_indexed_count", "4")], )lines 146–146conn.commit()lines 150–150scope = index_scope(db)lines 152–152assert scope.not_indexed == (".sh=3", ".yml=1")lines 153–153assert scope.not_indexed_count == 4