chore: suppress false-positive S105 lint on ModerationVerdict.PASS
Some checks failed
Tests / lint (pull_request) Successful in 13s
Tests / test (pull_request) Failing after 25m48s

This commit is contained in:
hermes
2026-03-23 11:06:02 -04:00
parent dd65586b5e
commit 5da29c4e00
5 changed files with 138 additions and 81 deletions

View File

@@ -193,9 +193,7 @@ class TestContentModerator:
layer="llama_guard",
category=ViolationCategory.VIOLENCE_GLORIFICATION,
)
with patch.object(
mod, "_run_guard", new_callable=AsyncMock, return_value=low_conf_result
):
with patch.object(mod, "_run_guard", new_callable=AsyncMock, return_value=low_conf_result):
result = await mod.check("sword fight scene", game="morrowind")
assert result.passed
assert not result.blocked
@@ -212,9 +210,7 @@ class TestContentModerator:
layer="llama_guard",
category=ViolationCategory.REAL_WORLD_HARM,
)
with patch.object(
mod, "_run_guard", new_callable=AsyncMock, return_value=high_conf_result
):
with patch.object(mod, "_run_guard", new_callable=AsyncMock, return_value=high_conf_result):
result = await mod.check("harmful content", game="morrowind")
assert result.blocked
@@ -229,9 +225,7 @@ class TestContentModerator:
def test_regex_passes_game_violence(self):
"""Regex should not flag in-game violence narration."""
mod = self._make_moderator()
result = mod._check_with_regex(
"The warrior slays the dragon with a mighty blow."
)
result = mod._check_with_regex("The warrior slays the dragon with a mighty blow.")
assert result.passed
def test_regex_passes_normal_narration(self):
@@ -261,10 +255,14 @@ class TestContentModerator:
async def test_guard_fallback_on_error(self):
"""Should fall back to regex when guard model errors."""
mod = self._make_moderator()
with patch.object(
mod, "_is_guard_available", new_callable=AsyncMock, return_value=True
), patch.object(
mod, "_check_with_guard", new_callable=AsyncMock, side_effect=RuntimeError("timeout")
with (
patch.object(mod, "_is_guard_available", new_callable=AsyncMock, return_value=True),
patch.object(
mod,
"_check_with_guard",
new_callable=AsyncMock,
side_effect=RuntimeError("timeout"),
),
):
result = await mod.check("safe text", game="default")
# Should fall back to regex and pass

View File

@@ -132,7 +132,13 @@ class TestSovereigntyMetricsStore:
def test_graduation_targets_complete(self):
"""All expected metric types have graduation targets."""
expected = {"cache_hit_rate", "api_cost", "time_to_report", "human_involvement", "local_artifacts"}
expected = {
"cache_hit_rate",
"api_cost",
"time_to_report",
"human_involvement",
"local_artifacts",
}
assert set(GRADUATION_TARGETS.keys()) == expected