test_requirements_section.py¶
tests/test_requirements_section.py
One top-level `requirements:` section, read by the index, the gate and the wiki (R5-CFG F6-F8/F14).
test_a_path_alone_is_the_file
None test_requirements_section.test_a_path_alone_is_the_file(Path tmp_path)
String shorthand.
tests/test_requirements_section.py:53
Checks
assert get_requirements(load_config(root / ".clew.yaml"))["file"] == "cat.yaml"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_a_path_alone_is_the_file → load_config |
| REQ-DDB-GUARD-024 | inferred | test_a_path_alone_is_the_file → load_config → apply_opt_in_languages |
Source · 9 lines
def test_a_path_alone_is_the_file(tmp_path: Path) -> None:
"""`requirements: cat.yaml` — the 1.x top-level form — stays the short way to say `file:`.
@brief String shorthand.
"""
root = _repo(tmp_path, "requirements: cat.yaml\n")
assert get_requirements(load_config(root / ".clew.yaml"))["file"] == "cat.yaml"
Activity · 2 steps
test_an_old_location_is_refused_with_a_pointer
None test_requirements_section.test_an_old_location_is_refused_with_a_pointer(Path tmp_path, str text, str pointer)
Moved keys point at their new home.
tests/test_requirements_section.py:84
Checks
assert pointer in " ".join(exc.value.problems), exc.value.problems
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_an_old_location_is_refused_with_a_pointer → load_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | inferred | test_an_old_location_is_refused_with_a_pointer → load_config → apply_opt_in_languages |
Source · 11 lines
def test_an_old_location_is_refused_with_a_pointer(tmp_path: Path, text: str, pointer: str) -> None:
"""Refused by name with where the key went, not as "unknown" — the key was right in 1.x.
@brief Moved keys point at their new home.
"""
root = _repo(tmp_path, text)
with pytest.raises(ConfigError) as exc:
load_config(root / ".clew.yaml")
assert pointer in " ".join(exc.value.problems), exc.value.problems
Activity · 4 steps
test_an_unknown_requirements_key_is_refused
None test_requirements_section.test_an_unknown_requirements_key_is_refused(Path tmp_path)
A misspelled catalog key is refused by name.
tests/test_requirements_section.py:62
Checks
assert "id_colum" in " ".join(exc.value.problems)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_an_unknown_requirements_key_is_refused → load_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | inferred | test_an_unknown_requirements_key_is_refused → load_config → apply_opt_in_languages |
Source · 22 lines
def test_an_unknown_requirements_key_is_refused(tmp_path: Path) -> None:
"""@brief A misspelled catalog key is refused by name."""
root = _repo(tmp_path, "requirements:\n file: cat.yaml\n id_colum: rid\n")
with pytest.raises(ConfigError) as exc:
load_config(root / ".clew.yaml")
assert "id_colum" in " ".join(exc.value.problems)
@pytest.mark.parametrize(
("text", "pointer"),
[
("guard:\n impact:\n requirements: {file: cat.yaml}\n", "requirements:"),
(
"guard:\n validate:\n version_gate: {version_field: v}\n",
"requirements.version_field",
),
(
"guard:\n validate:\n version_gate: {current_version: '1.0'}\n",
"validate.current_version",
),
],
)test_external_and_needs_reach_the_wiki_from_the_requirements_section
None test_requirements_section.test_external_and_needs_reach_the_wiki_from_the_requirements_section(Path tmp_path)
The wiki's catalogs come from `requirements.external`.
tests/test_requirements_section.py:128
Checks
assert not problems, problemsassert [(s.name, s.repo, s.pin, s.catalog) for s in config.catalogs] == [assert config.needs == "docs/needs.json"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_external_and_needs_reach_the_wiki_from_the_requirements_section → load_wiki_config → _requirements_section → read_requirements_section |
| REQ-DDB-WIKI-054 | inferred | test_external_and_needs_reach_the_wiki_from_the_requirements_section → load_wiki_config → _comments → all |
Source · 18 lines
def test_external_and_needs_reach_the_wiki_from_the_requirements_section(tmp_path: Path) -> None:
"""F6: one pinned-catalog shape, `{repo, rev, path, name}`; the wiki reads it from here.
@brief The wiki's catalogs come from `requirements.external`.
"""
from clew.wiki.config import load_wiki_config
root = _repo(
tmp_path,
"requirements:\n file: cat.yaml\n needs: docs/needs.json\n"
" external:\n - {repo: ../kv, rev: v1.2.0, path: req.yaml, name: kv}\n",
)
config, problems = load_wiki_config(root)
assert not problems, problems
assert [(s.name, s.repo, s.pin, s.catalog) for s in config.catalogs] == [
("kv", "../kv", "v1.2.0", "req.yaml")
]
assert config.needs == "docs/needs.json"1 more lines, not shown
Activity · 6 steps
test_one_default_column_pair_for_every_reader
None test_requirements_section.test_one_default_column_pair_for_every_reader()
One default pair.
tests/test_requirements_section.py:115
Checks
assert resolve_catalog_columns(None) == (REQUIREMENTS_ID_COLUMN_DEFAULT, REQUIREMENTS_NAME_COLUMN_DEFAULT, )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_one_default_column_pair_for_every_reader → resolve_catalog_columns |
Source · 13 lines
def test_one_default_column_pair_for_every_reader() -> None:
"""F8: an undeclared flat catalog is read with the same id/name keys by gate and index.
@brief One default pair.
"""
from clew.guard.config import REQUIREMENTS_ID_COLUMN_DEFAULT, REQUIREMENTS_NAME_COLUMN_DEFAULT
assert resolve_catalog_columns(None) == (
REQUIREMENTS_ID_COLUMN_DEFAULT,
REQUIREMENTS_NAME_COLUMN_DEFAULT,
)
Activity · 2 steps
test_the_current_version_is_read_from_its_new_key
None test_requirements_section.test_the_current_version_is_read_from_its_new_key(Path tmp_path)
`validate.current_version` is the release the version gate compares against.
tests/test_requirements_section.py:95
Checks
assert load_config(root / ".clew.yaml")["validate"]["current_version"] == "2.0.0"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_the_current_version_is_read_from_its_new_key → load_config |
| REQ-DDB-GUARD-024 | measured | test_the_current_version_is_read_from_its_new_key → load_config → apply_opt_in_languages |
Source · 9 lines
def test_the_current_version_is_read_from_its_new_key(tmp_path: Path) -> None:
"""@brief `validate.current_version` is the release the version gate compares against."""
root = _repo(tmp_path, "guard:\n validate:\n current_version: '2.0.0'\n")
assert load_config(root / ".clew.yaml")["validate"]["current_version"] == "2.0.0"
@pytest.mark.parametrize(
("key", "pointer"), [("catalogs", "requirements.external"), ("needs", "requirements.needs")]
)test_the_gate_and_the_index_read_the_same_top_level_section
None test_requirements_section.test_the_gate_and_the_index_read_the_same_top_level_section(Path tmp_path)
One section, both readers.
tests/test_requirements_section.py:40
Called by none
Calls _repo, get_requirements, load_config, load_guard_config, resolve_catalog_columns, resolve_catalog_path
Checks
assert gate["file"] == "cat.yaml" and gate["id_column"] == "rid"assert resolve_catalog_path(index_cfg, root) == (root / "cat.yaml").resolve()assert resolve_catalog_columns(index_cfg) == ("rid", "label")
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_the_gate_and_the_index_read_the_same_top_level_section → load_guard_config |
| REQ-DDB-GUARD-012 | measured | test_the_gate_and_the_index_read_the_same_top_level_section → load_config |
| REQ-DDB-GUARD-024 | inferred | test_the_gate_and_the_index_read_the_same_top_level_section → load_config → apply_opt_in_languages |
| REQ-DDB-SCHEMA-006 | measured | test_the_gate_and_the_index_read_the_same_top_level_section → resolve_catalog_path |
Source · 13 lines
def test_the_gate_and_the_index_read_the_same_top_level_section(tmp_path: Path) -> None:
"""With NO `guard:` section at all: the catalog is the repo's, not the gate's.
@brief One section, both readers.
"""
root = _repo(tmp_path, _SECTION)
gate = get_requirements(load_config(root / ".clew.yaml"))
assert gate["file"] == "cat.yaml" and gate["id_column"] == "rid"
index_cfg = load_guard_config(root)
assert resolve_catalog_path(index_cfg, root) == (root / "cat.yaml").resolve()
assert resolve_catalog_columns(index_cfg) == ("rid", "label")
Activity · 6 steps
test_the_wiki_catalog_keys_point_at_the_requirements_section
None test_requirements_section.test_the_wiki_catalog_keys_point_at_the_requirements_section(Path tmp_path, str key, str pointer)
`wiki.catalogs` / `wiki.needs` moved to `requirements:`.
tests/test_requirements_section.py:104
Checks
assert any(pointer in p for p in problems), problems
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_the_wiki_catalog_keys_point_at_the_requirements_section → load_wiki_config → _requirements_section → read_requirements_section |
| REQ-DDB-WIKI-054 | inferred | test_the_wiki_catalog_keys_point_at_the_requirements_section → load_wiki_config → _comments → all |
Source · 11 lines
def test_the_wiki_catalog_keys_point_at_the_requirements_section(
tmp_path: Path, key: str, pointer: str
) -> None:
"""@brief `wiki.catalogs` / `wiki.needs` moved to `requirements:`."""
from clew.wiki.config import load_wiki_config
root = _repo(tmp_path, f"wiki:\n {key}: []\n")
_config, problems = load_wiki_config(root)
assert any(pointer in p for p in problems), problems