"""Tests for Family 2: Trivial Bypass attacks."""

from rewardprobe.families.trivial_bypass import TrivialBypassFamily


class TestTrivialBypassFamily:
    def test_substring_match_catches_bypasses(self, buggy_env):
        family = TrivialBypassFamily()
        result = family.run(buggy_env)
        attack_names = {f.attack for f in result.findings}
        # Substring match should be caught by echo_prompt and constant_output
        assert "echo_prompt" in attack_names or "constant_output" in attack_names

    def test_clean_env_passes(self, clean_env):
        family = TrivialBypassFamily()
        result = family.run(clean_env)
        # Exact match should pass echo_prompt and constant_output
        assert result.passed >= 2

    def test_always_one_catches_constant(self, always_one_env):
        family = TrivialBypassFamily()
        result = family.run(always_one_env)
        attack_names = {f.attack for f in result.findings}
        assert "constant_output" in attack_names
        assert "echo_prompt" in attack_names

    def test_family_has_4_attacks(self):
        family = TrivialBypassFamily()
        assert len(family.attacks) == 4
