test_guard_exempt_when.py¶
tests/guard/test_guard_exempt_when.py
Exempt a requirement by any catalogue field, not only its status (#72 item 14, 2.1).
test_a_requirement_is_exempt_by_status_or_by_a_named_field
None test_guard_exempt_when.test_a_requirement_is_exempt_by_status_or_by_a_named_field()
The reason names the field and its value; neither match is None.
tests/guard/test_guard_exempt_when.py:22
Checks
assert exemption({"status": "planned"}, req) == "status: planned"assert (exemption({"status": "active", "responsibility": "Cloud"}, req) == "responsibility: Cloud" )assert exemption({"status": "active", "responsibility": "Library"}, req) is Noneassert exemption({"responsibility": "App"}, _req()) is None, ("no exempt_when, no field exemption" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-022 | measured | test_a_requirement_is_exempt_by_status_or_by_a_named_field → exemption |
Source · 13 lines
def test_a_requirement_is_exempt_by_status_or_by_a_named_field() -> None:
"""@brief The reason names the field and its value; neither match is None."""
req = _req(exempt_when={"responsibility": ["App", "Cloud"]})
assert exemption({"status": "planned"}, req) == "status: planned"
assert (
exemption({"status": "active", "responsibility": "Cloud"}, req) == "responsibility: Cloud"
)
assert exemption({"status": "active", "responsibility": "Library"}, req) is None
assert exemption({"responsibility": "App"}, _req()) is None, (
"no exempt_when, no field exemption"
)
Activity · 5 steps
test_coverage_lists_an_exempt_requirement_with_its_reason
None test_guard_exempt_when.test_coverage_lists_an_exempt_requirement_with_its_reason()
`clew guard coverage` says why each one is exempt.
tests/guard/test_guard_exempt_when.py:35
Checks
assert _exempt(rows, {"REQ-A-001", "REQ-A-002"}, config) == [
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-022 | measured | test_coverage_lists_an_exempt_requirement_with_its_reason → _exempt |
Source · 14 lines
def test_coverage_lists_an_exempt_requirement_with_its_reason() -> None:
"""@brief `clew guard coverage` says why each one is exempt."""
from clew.guard.coverage import _exempt
rows = {
"REQ-A-001": {"status": "active", "responsibility": "App"},
"REQ-A-002": {"status": "active"},
}
config = {"requirements": _req(exempt_when={"responsibility": ["App"]})}
assert _exempt(rows, {"REQ-A-001", "REQ-A-002"}, config) == [
{"req_id": "REQ-A-001", "status": "active", "reason": "responsibility: App"}
]
Activity · 4 steps
test_exempt_when_must_map_fields_to_lists
None test_guard_exempt_when.test_exempt_when_must_map_fields_to_lists()
A string where the list belongs is refused, as everywhere in the schema.
tests/guard/test_guard_exempt_when.py:49
Checks
assert any("exempt_when" in e and "list" in e for e in errors), errors
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_exempt_when_must_map_fields_to_lists → _validate_node |
Source · 6 lines
def test_exempt_when_must_map_fields_to_lists() -> None:
"""@brief A string where the list belongs is refused, as everywhere in the schema."""
errors = _validate_node(
{"exempt_when": {"responsibility": "App"}}, REQUIREMENTS_SCHEMA, "requirements"
)
assert any("exempt_when" in e and "list" in e for e in errors), errors1 more lines, not shown