test_guard_config.py¶
tests/guard/test_guard_config.py
Tests for clew.guard.config (absorbed from doxygen-guard).
test_absolute_path_rejected
test_guard_config.TestValidateOutputPath.test_absolute_path_rejected(self)
tests/guard/test_guard_config.py:313
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | inferred | test_absolute_path_rejected → validate_output_path → resolve_contained_path |
Source · 4 lines
def test_absolute_path_rejected(self):
with pytest.raises(ConfigError, match="must be relative"):
validate_output_path("/etc/cron.d")
Activity · 2 steps
test_an_x_key_is_an_unknown_key
test_guard_config.TestNoPassthroughKeys.test_an_x_key_is_an_unknown_key(self)
tests/guard/test_guard_config.py:365
Checks
assert len(errors) == 1assert "x-tool" in errors[0]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_an_x_key_is_an_unknown_key → validate_config_schema |
Source · 5 lines
def test_an_x_key_is_an_unknown_key(self):
errors = validate_config_schema({"x-tool": {}})
assert len(errors) == 1
assert "x-tool" in errors[0]
Activity · 3 steps
test_basic
test_guard_config.TestParseVersion.test_basic(self)
tests/guard/test_guard_config.py:272
Checks
assert parse_version("v1.8.2") == (1, 8, 2)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-014 | measured | test_basic → parse_version |
| REQ-DDB-GUARD-022 | measured |
Source · 3 lines
def test_basic(self):
assert parse_version("v1.8.2") == (1, 8, 2)
Activity · 1 steps
test_build_metadata
test_guard_config.TestParseVersion.test_build_metadata(self)
tests/guard/test_guard_config.py:287
Checks
assert parse_version("v2.1.0+build123") == (2, 1, 0)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-014 | measured | test_build_metadata → parse_version |
Source · 3 lines
def test_build_metadata(self):
assert parse_version("v2.1.0+build123") == (2, 1, 0)
Activity · 1 steps
test_c_file
test_guard_config.TestGetLanguageConfig.test_c_file(self)
tests/guard/test_guard_config.py:174
Checks
assert result is not Noneassert ".c" in result["extensions"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-013 | measured | test_c_file → get_language_config |
Source · 6 lines
def test_c_file(self):
config = CONFIG_DEFAULTS
result = get_language_config(config, "src/main.c")
assert result is not None
assert ".c" in result["extensions"]
Activity · 4 steps
test_config_error_is_caught_by_except_exception
test_guard_config.TestConfigErrorContract.test_config_error_is_caught_by_except_exception(self, tmp_path)
The whole point of issue #5: SystemExit escaped `except Exception`.
tests/guard/test_guard_config.py:346
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_config_error_is_caught_by_except_exception → load_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | inferred | test_config_error_is_caught_by_except_exception → load_config → apply_opt_in_languages |
Source · 9 lines
def test_config_error_is_caught_by_except_exception(self, tmp_path):
"""The whole point of issue #5: SystemExit escaped `except Exception`."""
config_file = self._write(tmp_path, "bogus_key: 1\n")
try:
load_config(config_file)
except Exception:
return
pytest.fail("load_config did not raise a catchable Exception")
Activity · 6 steps
test_cpp_file
test_guard_config.TestGetLanguageConfig.test_cpp_file(self)
tests/guard/test_guard_config.py:186
Checks
assert result is not Noneassert ".cpp" in result["extensions"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-013 | measured | test_cpp_file → get_language_config |
Source · 6 lines
def test_cpp_file(self):
config = CONFIG_DEFAULTS
result = get_language_config(config, "src/app.cpp")
assert result is not None
assert ".cpp" in result["extensions"]
Activity · 4 steps
test_custom_tags
test_guard_config.TestLoadConfig.test_custom_tags(self, tmp_path)
tests/guard/test_guard_config.py:95
Checks
assert "req" in config["validate"]["tags"]assert config["validate"]["tags"]["req"]["pattern"] == r"^REQ-\w+$"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_custom_tags → load_config |
| REQ-DDB-GUARD-024 | measured | test_custom_tags → load_config → apply_opt_in_languages |
Source · 16 lines
def test_custom_tags(self, tmp_path):
config_file = tmp_path / ".clew.yaml"
config_file.write_text(
guard_yaml(
dedent("""\
validate:
tags:
req:
pattern: "^REQ-\\\\w+$"
""")
)
)
config = load_config(config_file)
assert "req" in config["validate"]["tags"]
assert config["validate"]["tags"]["req"]["pattern"] == r"^REQ-\w+$"
Activity · 5 steps
test_empty_config_file_returns_defaults
test_guard_config.TestLoadConfig.test_empty_config_file_returns_defaults(self, tmp_path)
tests/guard/test_guard_config.py:73
Checks
assert config == CONFIG_DEFAULTS
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_empty_config_file_returns_defaults → load_config |
| REQ-DDB-GUARD-024 | inferred | test_empty_config_file_returns_defaults → load_config → apply_opt_in_languages |
Source · 6 lines
def test_empty_config_file_returns_defaults(self, tmp_path):
config_file = tmp_path / ".clew.yaml"
config_file.write_text(guard_yaml(""))
config = load_config(config_file)
assert config == CONFIG_DEFAULTS
Activity · 4 steps
test_empty_config_passes
test_guard_config.TestValidateConfigSchema.test_empty_config_passes(self)
tests/guard/test_guard_config.py:206
Checks
assert validate_config_schema({}) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_empty_config_passes → validate_config_schema |
Source · 3 lines
def test_empty_config_passes(self):
assert validate_config_schema({}) == []
Activity · 1 steps
test_every_default_key_is_permitted_by_the_schema
test_guard_config.TestSchemaMatchesImplementation.test_every_default_key_is_permitted_by_the_schema(self)
Anything with a default must be settable, or the default is unreachable.
tests/guard/test_guard_config.py:413
Checks
assert errors == [], errors
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_every_default_key_is_permitted_by_the_schema → validate_config_schema |
Source · 5 lines
def test_every_default_key_is_permitted_by_the_schema(self):
"""Anything with a default must be settable, or the default is unreachable."""
errors = validate_config_schema({"validate": CONFIG_DEFAULTS["validate"]})
assert errors == [], errors
Activity · 2 steps
test_every_documented_presence_key_loads
test_guard_config.TestSchemaMatchesImplementation.test_every_documented_presence_key_loads(self, tmp_path)
tests/guard/test_guard_config.py:406
Checks
assert config["validate"]["presence"][key] is True, key
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_every_documented_presence_key_loads → load_config |
| REQ-DDB-GUARD-024 | measured | test_every_documented_presence_key_loads → load_config → apply_opt_in_languages |
Source · 7 lines
def test_every_documented_presence_key_loads(self, tmp_path):
for key in ("require_doxygen", "require_return", "require_file_doxygen"):
config_file = tmp_path / ".clew.yaml"
config_file.write_text(guard_yaml(f"validate:\n presence:\n {key}: true\n"))
config = load_config(config_file)
assert config["validate"]["presence"][key] is True, key
Activity · 5 steps
test_exclude_patterns
test_guard_config.TestLoadConfig.test_exclude_patterns(self, tmp_path)
tests/guard/test_guard_config.py:154
Checks
assert config["validate"]["exclude"] == ["re:^gen/", "vendor/"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_exclude_patterns → load_config |
| REQ-DDB-GUARD-024 | measured | test_exclude_patterns → load_config → apply_opt_in_languages |
Source · 17 lines
def test_exclude_patterns(self, tmp_path):
config_file = tmp_path / ".clew.yaml"
config_file.write_text(
guard_yaml(
dedent("""\
validate:
exclude:
- "re:^gen/"
- "vendor/"
""")
)
)
## 2.0.0 (R5-CFG F18): excludes are globs; a regex is written `re:`.
config = load_config(config_file)
assert config["validate"]["exclude"] == ["re:^gen/", "vendor/"]
Activity · 4 steps
test_full_config
test_guard_config.TestLoadConfig.test_full_config(self, tmp_path)
tests/guard/test_guard_config.py:122
Checks
assert "kotlin" in config["validate"]["languages"]assert config["validate"]["version"]["tag"] == "@ver"assert config["validate"]["exclude"] == ["gen/**"]assert config["impact"]["report_dir"] == "docs/out/"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_full_config → load_config |
| REQ-DDB-GUARD-024 | measured | test_full_config → load_config → apply_opt_in_languages |
Source · 26 lines
def test_full_config(self, tmp_path):
config_file = tmp_path / ".clew.yaml"
config_file.write_text(
guard_yaml(
dedent("""\
impact:
report_dir: docs/out/
validate:
languages:
kotlin:
extensions: [.kt]
function_pattern: "public\\\\s+\\\\w+"
exclude_names: []
version:
tag: "@ver"
exclude:
- "gen/**"
""")
)
)
config = load_config(config_file)
assert "kotlin" in config["validate"]["languages"]
assert config["validate"]["version"]["tag"] == "@ver"
assert config["validate"]["exclude"] == ["gen/**"]
assert config["impact"]["report_dir"] == "docs/out/"
Activity · 7 steps
test_header_file
test_guard_config.TestGetLanguageConfig.test_header_file(self)
tests/guard/test_guard_config.py:180
Checks
assert result is not Noneassert ".h" in result["extensions"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-013 | measured | test_header_file → get_language_config |
Source · 6 lines
def test_header_file(self):
config = CONFIG_DEFAULTS
result = get_language_config(config, "include/driver.h")
assert result is not None
assert ".h" in result["extensions"]
Activity · 4 steps
test_impact_section_override
test_guard_config.TestLoadConfig.test_impact_section_override(self, tmp_path)
tests/guard/test_guard_config.py:111
Checks
assert config["requirements"]["file"] == "reqs.csv"assert config["impact"]["report_dir"] == "out/impact/"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_impact_section_override → load_config |
| REQ-DDB-GUARD-024 | measured | test_impact_section_override → load_config → apply_opt_in_languages |
Source · 11 lines
def test_impact_section_override(self, tmp_path):
## 2.0.0 (R5-CFG F7/F9/F14): the key this tested moved; the test follows it.
config_file = tmp_path / ".clew.yaml"
config_file.write_text(
"requirements:\n file: reqs.csv\n format: csv\n"
+ guard_yaml("impact:\n report_dir: out/impact/\n")
)
config = load_config(config_file)
assert config["requirements"]["file"] == "reqs.csv"
assert config["impact"]["report_dir"] == "out/impact/"
Activity · 5 steps
test_invalid_raises
test_guard_config.TestParseVersion.test_invalid_raises(self)
An unparseable version must fail loudly, not sort as (0,).
tests/guard/test_guard_config.py:290
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-014 | measured | test_invalid_raises → parse_version |
Source · 12 lines
def test_invalid_raises(self):
"""An unparseable version must fail loudly, not sort as (0,).
Returning (0,) made every catalogued requirement compare as not-yet-active,
which silently disabled the whole @req coverage gate while the run still
exited 0 — the worst case being a shallow CI clone where "auto:git" resolves
to nothing.
"""
with pytest.raises(ConfigError, match="Could not parse version"):
parse_version("not-a-version")
Activity · 2 steps
test_language_dicts_are_deep_copied
test_guard_config.TestDefaultsAreNotAliased.test_language_dicts_are_deep_copied(self, tmp_path)
tests/guard/test_guard_config.py:466
Checks
assert ".leaked" not in CONFIG_DEFAULTS["validate"]["languages"]["c"]["extensions"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_language_dicts_are_deep_copied → load_config |
| REQ-DDB-GUARD-024 | inferred | test_language_dicts_are_deep_copied → load_config → apply_opt_in_languages |
Source · 4 lines
def test_language_dicts_are_deep_copied(self, tmp_path):
config = load_config(tmp_path / "nonexistent.yaml")
config["validate"]["languages"]["c"]["extensions"].append(".leaked")
assert ".leaked" not in CONFIG_DEFAULTS["validate"]["languages"]["c"]["extensions"]1 more lines, not shown
Activity · 3 steps
test_mid_path_traversal_rejected
test_guard_config.TestValidateOutputPath.test_mid_path_traversal_rejected(self)
tests/guard/test_guard_config.py:321
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | inferred | test_mid_path_traversal_rejected → validate_output_path → resolve_contained_path |
Source · 5 lines
def test_mid_path_traversal_rejected(self):
with pytest.raises(ConfigError, match="directory traversal"):
validate_output_path("docs/../../etc")
Activity · 2 steps
test_multiple_errors
test_guard_config.TestValidateConfigSchema.test_multiple_errors(self)
tests/guard/test_guard_config.py:264
Checks
assert len(errors) == 2
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_multiple_errors → validate_config_schema |
Source · 5 lines
def test_multiple_errors(self):
errors = validate_config_schema({"bogus1": 1, "bogus2": 2})
assert len(errors) == 2
Activity · 2 steps
test_mutating_a_loaded_config_does_not_touch_the_defaults
test_guard_config.TestDefaultsAreNotAliased.test_mutating_a_loaded_config_does_not_touch_the_defaults(self, tmp_path)
tests/guard/test_guard_config.py:452
Checks
assert CONFIG_DEFAULTS["validate"]["exclude"] == beforeassert "_resolved" not in CONFIG_DEFAULTS["validate"].get("version_gate", {})
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_mutating_a_loaded_config_does_not_touch_the_defaults → load_config |
| REQ-DDB-GUARD-024 | inferred | test_mutating_a_loaded_config_does_not_touch_the_defaults → load_config → apply_opt_in_languages |
Source · 8 lines
def test_mutating_a_loaded_config_does_not_touch_the_defaults(self, tmp_path):
before = list(CONFIG_DEFAULTS["validate"]["exclude"])
config = load_config(tmp_path / "nonexistent.yaml")
config["validate"]["exclude"].append("^leaked/")
config["validate"].setdefault("version_gate", {})["_resolved"] = "v9.9.9"
assert CONFIG_DEFAULTS["validate"]["exclude"] == before
assert "_resolved" not in CONFIG_DEFAULTS["validate"].get("version_gate", {})
Activity · 6 steps
test_nested_relative_passes
test_guard_config.TestValidateOutputPath.test_nested_relative_passes(self)
tests/guard/test_guard_config.py:309
Checks
assert len(result.parts) == 3
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-016 | measured | test_nested_relative_passes → validate_output_path → resolve_contained_path |
Source · 4 lines
def test_nested_relative_passes(self):
result = validate_output_path("docs/generated/sequences")
assert len(result.parts) == 3
Activity · 2 steps
test_nested_sections_are_independent_objects
test_guard_config.TestDefaultsAreNotAliased.test_nested_sections_are_independent_objects(self, tmp_path)
tests/guard/test_guard_config.py:447
Checks
assert config["validate"] is not CONFIG_DEFAULTS["validate"]assert config["impact"] is not CONFIG_DEFAULTS["impact"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_nested_sections_are_independent_objects → load_config |
| REQ-DDB-GUARD-024 | inferred | test_nested_sections_are_independent_objects → load_config → apply_opt_in_languages |
Source · 5 lines
def test_nested_sections_are_independent_objects(self, tmp_path):
config = load_config(tmp_path / "nonexistent.yaml")
assert config["validate"] is not CONFIG_DEFAULTS["validate"]
assert config["impact"] is not CONFIG_DEFAULTS["impact"]
Activity · 3 steps
test_no_config_file_returns_defaults
test_guard_config.TestLoadConfig.test_no_config_file_returns_defaults(self, tmp_path)
tests/guard/test_guard_config.py:69
Checks
assert config == CONFIG_DEFAULTS
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_no_config_file_returns_defaults → load_config |
| REQ-DDB-GUARD-024 | inferred | test_no_config_file_returns_defaults → load_config → apply_opt_in_languages |
Source · 4 lines
def test_no_config_file_returns_defaults(self, tmp_path):
config = load_config(tmp_path / "nonexistent.yaml")
assert config == CONFIG_DEFAULTS
Activity · 2 steps
test_no_extension
test_guard_config.TestGetLanguageConfig.test_no_extension(self)
tests/guard/test_guard_config.py:197
Checks
assert result is None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-013 | measured | test_no_extension → get_language_config |
Source · 6 lines
def test_no_extension(self):
config = CONFIG_DEFAULTS
result = get_language_config(config, "Makefile")
assert result is None
Activity · 3 steps
test_no_prefix
test_guard_config.TestParseVersion.test_no_prefix(self)
tests/guard/test_guard_config.py:275
Checks
assert parse_version("1.8.2") == (1, 8, 2)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-014 | measured | test_no_prefix → parse_version |
Source · 3 lines
def test_no_prefix(self):
assert parse_version("1.8.2") == (1, 8, 2)
Activity · 1 steps
test_no_suggestion_when_nothing_is_close
test_guard_config.TestDidYouMean.test_no_suggestion_when_nothing_is_close(self)
tests/guard/test_guard_config.py:391
Checks
assert "did you mean" not in errors[0]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_no_suggestion_when_nothing_is_close → validate_config_schema |
Source · 5 lines
def test_no_suggestion_when_nothing_is_close(self):
errors = validate_config_schema({"zzzzzzzz": {}})
assert "did you mean" not in errors[0]
Activity · 2 steps
test_non_dict_where_dict_expected
test_guard_config.TestValidateConfigSchema.test_non_dict_where_dict_expected(self)
tests/guard/test_guard_config.py:259
Checks
assert len(errors) == 1assert "expected dict" in errors[0]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_non_dict_where_dict_expected → validate_config_schema |
Source · 5 lines
def test_non_dict_where_dict_expected(self):
errors = validate_config_schema({"validate": "garbage"})
assert len(errors) == 1
assert "expected dict" in errors[0]
Activity · 3 steps
test_non_mapping_config_returns_defaults
test_guard_config.TestLoadConfig.test_non_mapping_config_returns_defaults(self, tmp_path)
tests/guard/test_guard_config.py:148
Checks
assert config == CONFIG_DEFAULTS
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_non_mapping_config_returns_defaults → load_config |
| REQ-DDB-GUARD-024 | inferred | test_non_mapping_config_returns_defaults → load_config → apply_opt_in_languages |
Source · 6 lines
def test_non_mapping_config_returns_defaults(self, tmp_path):
config_file = tmp_path / ".clew.yaml"
config_file.write_text("just a string")
config = load_config(config_file)
assert config == CONFIG_DEFAULTS
Activity · 4 steps
test_open_dict_allows_custom_languages
test_guard_config.TestValidateConfigSchema.test_open_dict_allows_custom_languages(self)
tests/guard/test_guard_config.py:234
Checks
assert errors == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_open_dict_allows_custom_languages → validate_config_schema |
Source · 6 lines
def test_open_dict_allows_custom_languages(self):
errors = validate_config_schema(
{"validate": {"languages": {"rust": {"extensions": [".rs"]}}}}
)
assert errors == []
Activity · 2 steps
test_open_dict_allows_custom_tags
test_guard_config.TestValidateConfigSchema.test_open_dict_allows_custom_tags(self)
tests/guard/test_guard_config.py:240
Checks
assert errors == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_open_dict_allows_custom_tags → validate_config_schema |
Source · 4 lines
def test_open_dict_allows_custom_tags(self):
errors = validate_config_schema({"validate": {"tags": {"custom_tag": {"pattern": ".*"}}}})
assert errors == []
Activity · 2 steps
test_partial_validate_override
test_guard_config.TestLoadConfig.test_partial_validate_override(self, tmp_path)
tests/guard/test_guard_config.py:79
Checks
assert config["validate"]["presence"]["require_doxygen"] is Falseassert "c" in config["validate"]["languages"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_partial_validate_override → load_config |
| REQ-DDB-GUARD-024 | measured | test_partial_validate_override → load_config → apply_opt_in_languages |
Source · 16 lines
def test_partial_validate_override(self, tmp_path):
config_file = tmp_path / ".clew.yaml"
config_file.write_text(
guard_yaml(
dedent("""\
validate:
presence:
require_doxygen: false
""")
)
)
config = load_config(config_file)
assert config["validate"]["presence"]["require_doxygen"] is False
# Other defaults preserved
assert "c" in config["validate"]["languages"]
Activity · 5 steps
test_prerelease_version
test_guard_config.TestParseVersion.test_prerelease_version(self)
tests/guard/test_guard_config.py:284
Checks
assert parse_version("v1.0.0-rc1") == (1, 0, 0)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-014 | measured | test_prerelease_version → parse_version |
Source · 3 lines
def test_prerelease_version(self):
assert parse_version("v1.0.0-rc1") == (1, 0, 0)
Activity · 1 steps
test_relative_path_passes
test_guard_config.TestValidateOutputPath.test_relative_path_passes(self)
tests/guard/test_guard_config.py:305
Checks
assert result.parts[0] == "docs"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-016 | measured | test_relative_path_passes → validate_output_path → resolve_contained_path |
Source · 4 lines
def test_relative_path_passes(self):
result = validate_output_path("docs/generated/")
assert result.parts[0] == "docs"
Activity · 2 steps
test_removed_trace_section_rejected
test_guard_config.TestValidateConfigSchema.test_removed_trace_section_rejected(self)
tests/guard/test_guard_config.py:244
Checks
assert len(errors) == 1assert "trace" in errors[0]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_removed_trace_section_rejected → validate_config_schema |
Source · 5 lines
def test_removed_trace_section_rejected(self):
errors = validate_config_schema({"trace": {"format": "plantuml"}})
assert len(errors) == 1
assert "trace" in errors[0]
Activity · 3 steps
test_schema_leaves_round_trip_through_load_config
test_guard_config.TestSchemaMatchesImplementation.test_schema_leaves_round_trip_through_load_config(self, tmp_path)
Every scalar schema leaf under validate.* must survive load_config.
tests/guard/test_guard_config.py:418
Checks
assert scalars, "expected scalar leaves under validate.*"assert config["validate"][key] == sample[kind], key
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_schema_leaves_round_trip_through_load_config → load_config |
| REQ-DDB-GUARD-024 | measured | test_schema_leaves_round_trip_through_load_config → load_config → apply_opt_in_languages |
Source · 20 lines
def test_schema_leaves_round_trip_through_load_config(self, tmp_path):
"""Every scalar schema leaf under validate.* must survive load_config.
Guards the drift class directly: a schema key with no default, or a default
with no schema key, is caught here rather than by a user hitting it.
"""
import yaml as _yaml
from clew.guard.config import CONFIG_SCHEMA
scalars = {k: v for k, v in CONFIG_SCHEMA["validate"].items() if v in (bool, str, list)}
sample = {bool: True, str: "x", list: []}
assert scalars, "expected scalar leaves under validate.*"
for key, kind in scalars.items():
config_file = tmp_path / ".clew.yaml"
config_file.write_text(guard_yaml(_yaml.safe_dump({"validate": {key: sample[kind]}})))
config = load_config(config_file)
assert config["validate"][key] == sample[kind], key
Activity · 10 steps
test_single_part
test_guard_config.TestParseVersion.test_single_part(self)
tests/guard/test_guard_config.py:281
Checks
assert parse_version("v3") == (3,)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-014 | measured | test_single_part → parse_version |
Source · 3 lines
def test_single_part(self):
assert parse_version("v3") == (3,)
Activity · 1 steps
test_stale_test_mapping_rejected
test_guard_config.TestValidateConfigSchema.test_stale_test_mapping_rejected(self)
tests/guard/test_guard_config.py:249
Checks
assert len(errors) == 1assert "test_mapping" in errors[0]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_stale_test_mapping_rejected → validate_config_schema |
Source · 5 lines
def test_stale_test_mapping_rejected(self):
errors = validate_config_schema({"impact": {"test_mapping": []}})
assert len(errors) == 1
assert "test_mapping" in errors[0]
Activity · 3 steps
test_suggests_close_nested_key
test_guard_config.TestDidYouMean.test_suggests_close_nested_key(self)
tests/guard/test_guard_config.py:387
Checks
assert "did you mean 'exclude'?" in errors[0]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_suggests_close_nested_key → validate_config_schema |
Source · 4 lines
def test_suggests_close_nested_key(self):
errors = validate_config_schema({"validate": {"exclud": []}})
assert "did you mean 'exclude'?" in errors[0]
Activity · 2 steps
test_suggests_close_top_level_key
test_guard_config.TestDidYouMean.test_suggests_close_top_level_key(self)
tests/guard/test_guard_config.py:383
Checks
assert "did you mean 'validate'?" in errors[0]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_suggests_close_top_level_key → validate_config_schema |
Source · 4 lines
def test_suggests_close_top_level_key(self):
errors = validate_config_schema({"validat": {}})
assert "did you mean 'validate'?" in errors[0]
Activity · 2 steps
test_the_rest_of_clew_yaml_is_not_the_gates
test_guard_config.TestNoPassthroughKeys.test_the_rest_of_clew_yaml_is_not_the_gates(self, tmp_path)
tests/guard/test_guard_config.py:370
Checks
assert config["impact"]["report_dir"] == "o/"assert "index_scope" not in config
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_the_rest_of_clew_yaml_is_not_the_gates → load_config |
| REQ-DDB-GUARD-024 | measured | test_the_rest_of_clew_yaml_is_not_the_gates → load_config → apply_opt_in_languages |
Source · 10 lines
def test_the_rest_of_clew_yaml_is_not_the_gates(self, tmp_path):
config_file = tmp_path / ".clew.yaml"
config_file.write_text(
"index_scope:\n roots: [src]\n" + guard_yaml("impact:\n report_dir: o/\n")
)
config = load_config(config_file)
assert config["impact"]["report_dir"] == "o/"
assert "index_scope" not in config
Activity · 5 steps
test_traversal_rejected
test_guard_config.TestValidateOutputPath.test_traversal_rejected(self)
tests/guard/test_guard_config.py:317
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | inferred | test_traversal_rejected → validate_output_path → resolve_contained_path |
Source · 4 lines
def test_traversal_rejected(self):
with pytest.raises(ConfigError, match="directory traversal"):
validate_output_path("../outside")
Activity · 2 steps
test_two_loads_are_independent
test_guard_config.TestDefaultsAreNotAliased.test_two_loads_are_independent(self, tmp_path)
tests/guard/test_guard_config.py:460
Checks
assert "^from-first/" not in second["validate"]["exclude"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_two_loads_are_independent → load_config |
| REQ-DDB-GUARD-024 | inferred | test_two_loads_are_independent → load_config → apply_opt_in_languages |
Source · 6 lines
def test_two_loads_are_independent(self, tmp_path):
first = load_config(tmp_path / "nonexistent.yaml")
first["validate"]["exclude"].append("^from-first/")
second = load_config(tmp_path / "nonexistent.yaml")
assert "^from-first/" not in second["validate"]["exclude"]
Activity · 4 steps
test_two_parts
test_guard_config.TestParseVersion.test_two_parts(self)
tests/guard/test_guard_config.py:278
Checks
assert parse_version("v1.0") == (1, 0)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-014 | measured | test_two_parts → parse_version |
Source · 3 lines
def test_two_parts(self):
assert parse_version("v1.0") == (1, 0)
Activity · 1 steps
test_unknown_extension
test_guard_config.TestGetLanguageConfig.test_unknown_extension(self)
tests/guard/test_guard_config.py:192
Checks
assert result is None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-013 | measured | test_unknown_extension → get_language_config |
| REQ-DDB-GUARD-020 | measured |
Source · 5 lines
def test_unknown_extension(self):
config = CONFIG_DEFAULTS
result = get_language_config(config, "script.rs")
assert result is None
Activity · 3 steps
test_unknown_key_raises_config_error
test_guard_config.TestConfigErrorContract.test_unknown_key_raises_config_error(self, tmp_path)
tests/guard/test_guard_config.py:334
Checks
assert any("shared_key_patterns" in p for p in exc.value.problems)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_unknown_key_raises_config_error → load_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | inferred | test_unknown_key_raises_config_error → load_config → apply_opt_in_languages |
Source · 12 lines
def test_unknown_key_raises_config_error(self, tmp_path):
config_file = self._write(
tmp_path,
"""\
shared_key_patterns:
- foo
""",
)
with pytest.raises(ConfigError) as exc:
load_config(config_file)
assert any("shared_key_patterns" in p for p in exc.value.problems)
Activity · 4 steps
test_unknown_nested_key
test_guard_config.TestValidateConfigSchema.test_unknown_nested_key(self)
tests/guard/test_guard_config.py:218
Checks
assert len(errors) == 1assert "validate.bogus" in errors[0]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_unknown_nested_key → validate_config_schema |
Source · 5 lines
def test_unknown_nested_key(self):
errors = validate_config_schema({"validate": {"bogus": 1}})
assert len(errors) == 1
assert "validate.bogus" in errors[0]
Activity · 3 steps
test_unknown_top_level_key
test_guard_config.TestValidateConfigSchema.test_unknown_top_level_key(self)
tests/guard/test_guard_config.py:213
Checks
assert len(errors) == 1assert "bogus" in errors[0]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_unknown_top_level_key → validate_config_schema |
Source · 5 lines
def test_unknown_top_level_key(self):
errors = validate_config_schema({"bogus": 1})
assert len(errors) == 1
assert "bogus" in errors[0]
Activity · 3 steps
test_unreadable_yaml_raises_config_error
test_guard_config.TestConfigErrorContract.test_unreadable_yaml_raises_config_error(self, tmp_path)
tests/guard/test_guard_config.py:355
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_unreadable_yaml_raises_config_error → load_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | inferred | test_unreadable_yaml_raises_config_error → load_config → apply_opt_in_languages |
Source · 6 lines
def test_unreadable_yaml_raises_config_error(self, tmp_path):
config_file = self._write(tmp_path, "validate: [unclosed\n")
with pytest.raises(ConfigError):
load_config(config_file)
Activity · 3 steps
test_valid_output_dir
test_guard_config.TestValidateConfigSchema.test_valid_output_dir(self)
tests/guard/test_guard_config.py:209
Checks
assert validate_config_schema({"impact": {"report_dir": "docs/"}}) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_valid_output_dir → validate_config_schema |
Source · 4 lines
def test_valid_output_dir(self):
## 2.0.0 (R5-CFG F7/F9/F14): the key this tested moved; the test follows it.
assert validate_config_schema({"impact": {"report_dir": "docs/"}}) == []
Activity · 1 steps
test_version_gate_accepted
test_guard_config.TestValidateConfigSchema.test_version_gate_accepted(self)
tests/guard/test_guard_config.py:254
Checks
assert errors == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_version_gate_accepted → validate_config_schema |
Source · 5 lines
def test_version_gate_accepted(self):
## 2.0.0 (R5-CFG F7/F9/F14): the key this tested moved; the test follows it.
errors = validate_config_schema({"validate": {"current_version": "v1.0"}})
assert errors == []
Activity · 2 steps
test_wrong_type_bool
test_guard_config.TestValidateConfigSchema.test_wrong_type_bool(self)
tests/guard/test_guard_config.py:229
Checks
assert len(errors) == 1assert "expected bool" in errors[0]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_wrong_type_bool → validate_config_schema |
Source · 5 lines
def test_wrong_type_bool(self):
errors = validate_config_schema({"validate": {"presence": {"require_doxygen": "yes"}}})
assert len(errors) == 1
assert "expected bool" in errors[0]
Activity · 3 steps
test_wrong_type_string
test_guard_config.TestValidateConfigSchema.test_wrong_type_string(self)
tests/guard/test_guard_config.py:223
Checks
assert len(errors) == 1assert "expected str" in errors[0]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_wrong_type_string → validate_config_schema |
Source · 6 lines
def test_wrong_type_string(self):
## 2.0.0 (R5-CFG F7/F9/F14): the key this tested moved; the test follows it.
errors = validate_config_schema({"impact": {"report_dir": 123}})
assert len(errors) == 1
assert "expected str" in errors[0]