test_requirement_fields.py

tests/test_requirement_fields.py

IEEE 29148 requirement attributes reach the index; a key nothing reads is kept (S4; 2.0.0).

test_an_entry_with_nothing_extra_has_no_extra

None test_requirement_fields.test_an_entry_with_nothing_extra_has_no_extra(Path tmp_path, caplog)

`extra` is NULL (absent), not `{}`, when every key was read.

tests/test_requirement_fields.py:67

Checks

  • assert extra is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_an_entry_with_nothing_extra_has_no_extra → ingest_requirements_yaml → resolve_catalog_columns
REQ-DDB-CONFIG-003measuredtest_an_entry_with_nothing_extra_has_no_extra → ingest_requirements_yaml → _is_flat_req_list
REQ-DDB-SCHEMA-006measuredtest_an_entry_with_nothing_extra_has_no_extra → ingest_requirements_yaml
REQ-DDB-SCHEMA-015measuredtest_an_entry_with_nothing_extra_has_no_extra → ingest_requirements_yaml
REQ-DDB-WIKI-054inferredtest_an_entry_with_nothing_extra_has_no_extra → ingest_requirements_yaml → _is_flat_req_list → all
Source · 8 lines
def test_an_entry_with_nothing_extra_has_no_extra(tmp_path: Path, caplog) -> None:
    """@brief `extra` is NULL (absent), not `{}`, when every key was read."""
    catalog = tmp_path / "requirements.yaml"
    catalog.write_text("requirements:\n  REQ-B-001:\n    name: Close\n")
    db = tmp_path / "clew.db"
    ingest_requirements_yaml(db, catalog)
    (extra,) = sqlite3.connect(db).execute("SELECT extra FROM requirements").fetchone()
    assert extra is None

1 more lines, not shown

Activity · 6 steps
lines 69–69catalog = tmp_path / "requirements.yaml"lines 70–70catalog.write_text("requirements:\n REQ-B-001:\n name: Close\n")lines 71–71db = tmp_path / "clew.db"lines 72–72ingest_requirements_yaml(db, catalog)lines 73–73(extra,) = sqlite3.connect(db).execute("SELECT extra FROM requirements").fetchone()lines 74–74assert extra is None

test_an_unread_key_is_kept_and_named

None test_requirement_fields.test_an_unread_key_is_kept_and_named(Path tmp_path, caplog)

`risk` and `x-owner` are kept in `extra`, and the log names them.

tests/test_requirement_fields.py:60

Show on the map →

Called by none

Calls _row

Checks

  • assert json.loads(row["extra"]) == {"risk": "high", "x-owner": "platform"}
  • assert "risk" in caplog.text and "x-owner" in caplog.text

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_an_unread_key_is_kept_and_named → _row → ingest_requirements_yaml → resolve_catalog_columns
REQ-DDB-CONFIG-003measuredtest_an_unread_key_is_kept_and_named → _row → ingest_requirements_yaml → _is_flat_req_list
REQ-DDB-SCHEMA-006measuredtest_an_unread_key_is_kept_and_named → _row → ingest_requirements_yaml
REQ-DDB-SCHEMA-015measuredtest_an_unread_key_is_kept_and_named → _row → ingest_requirements_yaml
REQ-DDB-WIKI-054inferredtest_an_unread_key_is_kept_and_named → _row → ingest_requirements_yaml → _is_flat_req_list → all
Source · 7 lines
def test_an_unread_key_is_kept_and_named(tmp_path: Path, caplog) -> None:
    """@brief `risk` and `x-owner` are kept in `extra`, and the log names them."""
    row = _row(tmp_path, caplog)
    assert json.loads(row["extra"]) == {"risk": "high", "x-owner": "platform"}
    assert "risk" in caplog.text and "x-owner" in caplog.text

Activity · 3 steps
lines 62–62row = _row(tmp_path, caplog)lines 63–63assert json.loads(row["extra"]) == {"risk": "high", "x-owner": "platform"}lines 64–64assert "risk" in caplog.text and "x-owner" in caplog.text

test_the_29148_attributes_are_columns

None test_requirement_fields.test_the_29148_attributes_are_columns(Path tmp_path, caplog)

status / rationale / verification / parent land in their own columns.

tests/test_requirement_fields.py:49

Show on the map →

Called by none

Calls _row

Checks

  • assert (row["status"], row["rationale"], row["verification"], row["parent"]) == ("approved", "Callers need a handle.", "test", "REQ-SYS-001", )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_the_29148_attributes_are_columns → _row → ingest_requirements_yaml → resolve_catalog_columns
REQ-DDB-CONFIG-003measuredtest_the_29148_attributes_are_columns → _row → ingest_requirements_yaml → _is_flat_req_list
REQ-DDB-SCHEMA-006measuredtest_the_29148_attributes_are_columns → _row → ingest_requirements_yaml
REQ-DDB-SCHEMA-015measuredtest_the_29148_attributes_are_columns → _row → ingest_requirements_yaml
REQ-DDB-WIKI-054inferredtest_the_29148_attributes_are_columns → _row → ingest_requirements_yaml → _is_flat_req_list → all
Source · 11 lines
def test_the_29148_attributes_are_columns(tmp_path: Path, caplog) -> None:
    """@brief status / rationale / verification / parent land in their own columns."""
    row = _row(tmp_path, caplog)
    assert (row["status"], row["rationale"], row["verification"], row["parent"]) == (
        "approved",
        "Callers need a handle.",
        "test",
        "REQ-SYS-001",
    )

Activity · 2 steps
lines 51–51row = _row(tmp_path, caplog)lines 52–57assert (row["status"], row["rationale"], row["verification"], row["parent"]) == ( "approved", "Callers need a handle.", "test", "REQ-SYS-001", )