test_wiki_tuning.py

tests/test_wiki_tuning.py

Every build-time number the wiki assumed is a declared key (R5-CFG C1-C5, C7-C9, W6, W8, W13, D14).

test_a_measured_depth_bounds_measured_expansion

None test_wiki_tuning.test_a_measured_depth_bounds_measured_expansion(tuple[Path, Path] indexed)

derive_flow honours measured_depth.

tests/test_wiki_tuning.py:65

Show on the map →

Called by none

Calls derive_flow

Checks

  • assert ("load", "parse") in {(s.caller, s.callee) for s in deep.steps}
  • assert ("load", "parse") not in {(s.caller, s.callee) for s in held.steps}

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-003measured
REQ-DDB-PIPE-011measured
REQ-DDB-QUERY-001measuredtest_a_measured_depth_bounds_measured_expansion → derive_flow → connect
REQ-DDB-QUERY-003measuredtest_a_measured_depth_bounds_measured_expansion → derive_flow → qualified_name_of
REQ-DDB-QUERY-010measuredtest_a_measured_depth_bounds_measured_expansion → derive_flow → _entry_rowids → function_candidates
REQ-DDB-QUERY-015measured
REQ-DDB-WIKI-001measuredtest_a_measured_depth_bounds_measured_expansion → derive_flow
REQ-DDB-WIKI-041measuredtest_a_measured_depth_bounds_measured_expansion → derive_flow
Source · 14 lines
def test_a_measured_depth_bounds_measured_expansion(indexed: tuple[Path, Path]) -> None:  # noqa: F811
    """C1: a call measured as run expands past the flow's depth only up to `measured_depth`.

    @brief derive_flow honours measured_depth.
    """
    from clew.wiki.flow import derive_flow

    db, repo = indexed
    deep = derive_flow(db, repo, "main", depth=1, executed=_RAN_LOAD_ONLY)
    held = derive_flow(db, repo, "main", depth=1, executed=_RAN_LOAD_ONLY, measured_depth=1)
    assert ("load", "parse") in {(s.caller, s.callee) for s in deep.steps}
    assert ("load", "parse") not in {(s.caller, s.callee) for s in held.steps}

Activity · 6 steps
lines 70–70from clew.wiki.flow import derive_flowlines 72–72db, repo = indexedlines 73–73deep = derive_flow(db, repo, "main", depth=1, executed=_RAN_LOAD_ONLY)lines 74–74held = derive_flow(db, repo, "main", depth=1, executed=_RAN_LOAD_ONLY, measured_depth=1)lines 75–75assert ("load", "parse") in {(s.caller, s.callee) for s in deep.steps}lines 76–76assert ("load", "parse") not in {(s.caller, s.callee) for s in held.steps}

test_a_traced_run_names_the_interpreter_it_fell_back_to

None test_wiki_tuning.test_a_traced_run_names_the_interpreter_it_fell_back_to(Path tmp_path, pytest.LogCaptureFixture caplog)

The traced-run interpreter is declared or the fallback is said.

tests/test_wiki_tuning.py:90

Checks

  • assert interpreter_for(tmp_path) == Path(sys.executable)
  • assert any("interpreter" in r.message for r in caplog.records)
  • assert interpreter_for(tmp_path, declared="bin/py") == tmp_path / "bin/py"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-035measuredtest_a_traced_run_names_the_interpreter_it_fell_back_to → interpreter_for
Source · 19 lines
def test_a_traced_run_names_the_interpreter_it_fell_back_to(
    tmp_path: Path, caplog: pytest.LogCaptureFixture
) -> None:
    """W6: no venv found and none declared → clew's own interpreter, said at WARNING; a declared
    interpreter is used as given.

    @brief The traced-run interpreter is declared or the fallback is said.
    """
    import logging
    import sys

    from clew.wiki.tracerun import interpreter_for

    with caplog.at_level(logging.WARNING):
        assert interpreter_for(tmp_path) == Path(sys.executable)
    assert any("interpreter" in r.message for r in caplog.records)
    assert interpreter_for(tmp_path, declared="bin/py") == tmp_path / "bin/py"

Activity · 7 steps
lines 98–98import logginglines 99–99import syslines 101–101from clew.wiki.tracerun import interpreter_forlines 103–103with caplog.at_level(logging.WARNING)lines 104–104assert interpreter_for(tmp_path) == Path(sys.executable)lines 105–105assert any("interpreter" in r.message for r in caplog.records)lines 106–106assert interpreter_for(tmp_path, declared="bin/py") == tmp_path / "bin/py"

test_a_truncated_issue_fetch_says_so

None test_wiki_tuning.test_a_truncated_issue_fetch_says_so()

The cap is reported, not silent.

tests/test_wiki_tuning.py:133

Show on the map →

Called by none

Calls fetch_pages

Checks

  • assert len(rows) == 300 and truncated is True

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-028measuredtest_a_truncated_issue_fetch_says_so → fetch_pages
Source · 10 lines
def test_a_truncated_issue_fetch_says_so() -> None:
    """D14: the fetch stopped at its page cap and returned what it had with no disclosure.

    @brief The cap is reported, not silent.
    """
    from clew.wiki.issues import fetch_pages

    pages = iter([[{"n": i}] * 100 for i in range(60)])
    rows, truncated = fetch_pages(lambda page: next(pages), max_pages=3)
    assert len(rows) == 300 and truncated is True

1 more lines, not shown

Activity · 4 steps
lines 138–138from clew.wiki.issues import fetch_pageslines 140–140pages = iter([[{"n": i}] * 100 for i in range(60)])lines 141–141rows, truncated = fetch_pages(lambda page: next(pages), max_pages=3)lines 142–142assert len(rows) == 300 and truncated is True

test_every_key_is_read_and_a_bad_one_is_a_problem

None test_wiki_tuning.test_every_key_is_read_and_a_bad_one_is_a_problem(Path tmp_path)

Declared values are read; a non-positive or non-integer value is reported.

tests/test_wiki_tuning.py:43

Show on the map →

Called by none

Calls _config

Checks

  • assert not problems, problems
  • assert (config.measured_depth, config.measured_steps, config.path_depth) == (4, 50, 3)
  • assert (config.trace_depth, config.trace_timeout, config.trace_python) == (1, 30, ".tox/py/bin/python", )
  • assert (config.component_depth, config.web_max_ring, config.max_report_mb) == (3, 5, 8)
  • assert (config.flows[0].measured_depth, config.flows[0].max_steps) == (2, 9)
  • assert any("measured_depth" in p for p in problems) and any("max_ring" in p for p in problems)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_every_key_is_read_and_a_bad_one_is_a_problem → _config → load_wiki_config → _requirements_section → read_requirements_section
REQ-DDB-WIKI-054inferredtest_every_key_is_read_and_a_bad_one_is_a_problem → _config → load_wiki_config → _comments → all
Source · 22 lines
def test_every_key_is_read_and_a_bad_one_is_a_problem(tmp_path: Path) -> None:
    """@brief Declared values are read; a non-positive or non-integer value is reported."""
    config, problems = _config(
        tmp_path,
        "wiki:\n  measured_depth: 4\n  measured_steps: 50\n  path_depth: 3\n  trace_depth: 1\n"
        "  trace_timeout: 30\n  trace_python: .tox/py/bin/python\n  component_depth: 3\n"
        "  web: {max_ring: 5}\n  flows:\n    - {entry: main, measured_depth: 2, max_steps: 9}\n"
        "tests:\n  max_report_mb: 8\n",
    )
    assert not problems, problems
    assert (config.measured_depth, config.measured_steps, config.path_depth) == (4, 50, 3)
    assert (config.trace_depth, config.trace_timeout, config.trace_python) == (
        1,
        30,
        ".tox/py/bin/python",
    )
    assert (config.component_depth, config.web_max_ring, config.max_report_mb) == (3, 5, 8)
    assert (config.flows[0].measured_depth, config.flows[0].max_steps) == (2, 9)
    _config_, problems = _config(tmp_path, "wiki:\n  measured_depth: 0\n  web: {max_ring: x}\n")
    assert any("measured_depth" in p for p in problems) and any("max_ring" in p for p in problems)

Activity · 8 steps
lines 45–51config, problems = _config( tmp_path, "wiki:\n measured_depth: 4\n measured_steps: 50\n path_depth: 3\n trace_depth: 1\n" " trace_timeout: 30\n trace_python: .tox/py/bin/python\n component_depth: 3\n" " web: {max_ring: 5}\n flows:\n - {entry: main, measured_depth: 2, max_steps: 9}\n" "tests:\n max_report_mb: 8\n", )lines 52–52assert not problems, problemslines 53–53assert (config.measured_depth, config.measured_steps, config.path_depth) == (4, 50, 3)lines 54–58assert (config.trace_depth, config.trace_timeout, config.trace_python) == ( 1, 30, ".tox/py/bin/python", )lines 59–59assert (config.component_depth, config.web_max_ring, config.max_report_mb) == (3, 5, 8)lines 60–60assert (config.flows[0].measured_depth, config.flows[0].max_steps) == (2, 9)lines 61–61_config_, problems = _config(tmp_path, "wiki:\n measured_depth: 0\n web: {max_ring: x}\n")lines 62–62assert any("measured_depth" in p for p in problems) and any("max_ring" in p for p in problems)

test_the_defaults_are_the_former_constants

None test_wiki_tuning.test_the_defaults_are_the_former_constants(Path tmp_path)

Undeclared, every key is the value the code used to assume.

tests/test_wiki_tuning.py:33

Show on the map →

Called by none

Calls _config

Checks

  • assert not problems
  • assert (config.measured_depth, config.measured_steps) == (12, 400)
  • assert (config.path_depth, config.trace_depth, config.trace_timeout) == (12, 2, 600)
  • assert (config.component_depth, config.web_max_ring, config.trace_python) == (2, 8, None)
  • assert config.max_report_mb == 64

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_the_defaults_are_the_former_constants → _config → load_wiki_config → _requirements_section → read_requirements_section
REQ-DDB-WIKI-054inferredtest_the_defaults_are_the_former_constants → _config → load_wiki_config → _comments → all
Source · 10 lines
def test_the_defaults_are_the_former_constants(tmp_path: Path) -> None:
    """@brief Undeclared, every key is the value the code used to assume."""
    config, problems = _config(tmp_path, "wiki: {title: x}\n")
    assert not problems
    assert (config.measured_depth, config.measured_steps) == (12, 400)
    assert (config.path_depth, config.trace_depth, config.trace_timeout) == (12, 2, 600)
    assert (config.component_depth, config.web_max_ring, config.trace_python) == (2, 8, None)
    assert config.max_report_mb == 64

Activity · 6 steps
lines 35–35config, problems = _config(tmp_path, "wiki: {title: x}\n")lines 36–36assert not problemslines 37–37assert (config.measured_depth, config.measured_steps) == (12, 400)lines 38–38assert (config.path_depth, config.trace_depth, config.trace_timeout) == (12, 2, 600)lines 39–39assert (config.component_depth, config.web_max_ring, config.trace_python) == (2, 8, None)lines 40–40assert config.max_report_mb == 64

test_the_fast_tier_refuses_when_a_declared_catalog_changes

None test_wiki_tuning.test_the_fast_tier_refuses_when_a_declared_catalog_changes(Path tmp_path)

A declared catalog is a whole-index input.

tests/test_wiki_tuning.py:121

Show on the map →

Called by none

Calls config_inputs

Checks

  • assert "docs/reqs.yaml" in config_inputs(tmp_path)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_the_fast_tier_refuses_when_a_declared_catalog_changes → config_inputs → load_declaration
REQ-DDB-GUARD-012measuredtest_the_fast_tier_refuses_when_a_declared_catalog_changes → config_inputs → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node
REQ-DDB-WIKI-054inferredtest_the_fast_tier_refuses_when_a_declared_catalog_changes → config_inputs → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all
Source · 12 lines
def test_the_fast_tier_refuses_when_a_declared_catalog_changes(tmp_path: Path) -> None:
    """W13: the fast refresh matched only the basename `requirements.yaml`; a catalog declared at
    another path changed under it without the full build its derived edges need.

    @brief A declared catalog is a whole-index input.
    """
    from clew.fasttier import config_inputs

    (tmp_path / ".clew.yaml").write_text("requirements:\n  file: docs/reqs.yaml\n")
    assert "docs/reqs.yaml" in config_inputs(tmp_path)

Activity · 3 steps
lines 127–127from clew.fasttier import config_inputslines 129–129(tmp_path / ".clew.yaml").write_text("requirements:\n file: docs/reqs.yaml\n")lines 130–130assert "docs/reqs.yaml" in config_inputs(tmp_path)

test_the_gate_diffs_against_a_declared_base

None test_wiki_tuning.test_the_gate_diffs_against_a_declared_base(Path tmp_path)

guard.impact.base.

tests/test_wiki_tuning.py:109

Checks

  • assert impact_base(load_config(tmp_path / ".clew.yaml")) == "upstream/develop"
  • assert impact_base(load_config(tmp_path / "none.yaml")) == "origin/main"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_the_gate_diffs_against_a_declared_base → load_config
REQ-DDB-GUARD-024measuredtest_the_gate_diffs_against_a_declared_base → load_config → apply_opt_in_languages
Source · 12 lines
def test_the_gate_diffs_against_a_declared_base(tmp_path: Path) -> None:
    """W8: `guard.impact.base` is the branch the impact report diffs against.

    @brief guard.impact.base.
    """
    from clew.guard.config import impact_base, load_config

    (tmp_path / ".clew.yaml").write_text("guard:\n  impact:\n    base: upstream/develop\n")
    assert impact_base(load_config(tmp_path / ".clew.yaml")) == "upstream/develop"
    assert impact_base(load_config(tmp_path / "none.yaml")) == "origin/main"

Activity · 4 steps
lines 114–114from clew.guard.config import impact_base, load_configlines 116–116(tmp_path / ".clew.yaml").write_text("guard:\n impact:\n base: upstream/develop\n")lines 117–117assert impact_base(load_config(tmp_path / ".clew.yaml")) == "upstream/develop"lines 118–118assert impact_base(load_config(tmp_path / "none.yaml")) == "origin/main"

test_the_package_depth_is_declared

None test_wiki_tuning.test_the_package_depth_is_declared(Path tmp_path)

graph package depth.

tests/test_wiki_tuning.py:79

Show on the map →

Called by none

Calls package_of

Checks

  • assert package_of("src/main/java/com/acme/x.java") == "src/main"
  • assert package_of("src/main/java/com/acme/x.java", depth=4) == "src/main/java/com"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-019measuredtest_the_package_depth_is_declared → package_of
Source · 11 lines
def test_the_package_depth_is_declared(tmp_path: Path) -> None:
    """C7: `src/main/java/com/acme/x.java` is one package `src/main` at depth 2, deeper at 4.

    @brief graph package depth.
    """
    from clew.wiki.graph import package_of

    assert package_of("src/main/java/com/acme/x.java") == "src/main"
    assert package_of("src/main/java/com/acme/x.java", depth=4) == "src/main/java/com"

Activity · 3 steps
lines 84–84from clew.wiki.graph import package_oflines 86–86assert package_of("src/main/java/com/acme/x.java") == "src/main"lines 87–87assert package_of("src/main/java/com/acme/x.java", depth=4) == "src/main/java/com"