Skip to content

DeepTeam is a framework to red team LLMs and AI agents.

.

A-Vamshi161e29e7d6a2
diff --git a/tests/test_core/test_vulnerabilities/test_child_protection.py b/tests/test_core/test_vulnerabilities/test_child_protection.py
index 43f578fc..36de49da 100644
--- a/tests/test_core/test_vulnerabilities/test_child_protection.py
+++ b/tests/test_core/test_vulnerabilities/test_child_protection.py
@@ -10,7 +10,9 @@ class TestChildProtection:
def test_child_protection_all_types(self):
types = ["age_verification", "data_privacy", "exposure_interaction"]
child_protection = ChildProtection(types=types)
- assert sorted(type.value for type in child_protection.types) == sorted(types)
+ assert sorted(type.value for type in child_protection.types) == sorted(
+ types
+ )
def test_child_protection_all_types_default(self):
child_protection = ChildProtection()
@@ -21,36 +23,52 @@ class TestChildProtection:
def test_child_protection_age_verification(self):
types = ["age_verification"]
child_protection = ChildProtection(types=types)
- assert sorted(type.value for type in child_protection.types) == sorted(types)
+ assert sorted(type.value for type in child_protection.types) == sorted(
+ types
+ )
def test_child_protection_data_privacy(self):
types = ["data_privacy"]
child_protection = ChildProtection(types=types)
- assert sorted(type.value for type in child_protection.types) == sorted(types)
+ assert sorted(type.value for type in child_protection.types) == sorted(
+ types
+ )
def test_child_protection_exposure_interaction(self):
types = ["exposure_interaction"]
child_protection = ChildProtection(types=types)
- assert sorted(type.value for type in child_protection.types) == sorted(types)
+ assert sorted(type.value for type in child_protection.types) == sorted(
+ types
+ )
def test_child_protection_all_types_invalid(self):
- types = ["age_verification", "data_privacy", "exposure_interaction", "invalid"]
+ types = [
+ "age_verification",
+ "data_privacy",
+ "exposure_interaction",
+ "invalid",
+ ]
with pytest.raises(ValueError):
ChildProtection(types=types)
def test_simulate_attacks_returns_expected_cases(self):
child_protection = ChildProtection(types=["age_verification"])
- test_cases = child_protection.simulate_attacks(attacks_per_vulnerability_type=2)
+ test_cases = child_protection.simulate_attacks(
+ attacks_per_vulnerability_type=2
+ )
assert len(test_cases) == 2
assert all(isinstance(tc, RTTestCase) for tc in test_cases)
assert all(tc.vulnerability == "Child Protection" for tc in test_cases)
assert all(
- tc.vulnerability_type == ChildProtectionType.AGE_VERIFICATION for tc in test_cases
+ tc.vulnerability_type == ChildProtectionType.AGE_VERIFICATION
+ for tc in test_cases
)
def test_assess_returns_results(self):
- child_protection = ChildProtection(types=["data_privacy"], async_mode=False)
+ child_protection = ChildProtection(
+ types=["data_privacy"], async_mode=False
+ )
def dummy_model_callback(prompt):
# Provide a simple pass-through or minimal callback if required by your real env
@@ -64,7 +82,9 @@ class TestChildProtection:
assert child_protection.simulated_attacks is not None and isinstance(
child_protection.simulated_attacks, dict
)
- assert child_protection.res is not None and isinstance(child_protection.res, dict)
+ assert child_protection.res is not None and isinstance(
+ child_protection.res, dict
+ )
assert ChildProtectionType.DATA_PRIVACY in results
assert len(results[ChildProtectionType.DATA_PRIVACY]) == 1
test_case = results[ChildProtectionType.DATA_PRIVACY][0]
@@ -85,7 +105,9 @@ class TestChildProtection:
@pytest.mark.asyncio
async def test_a_assess_returns_async_results(self):
- child_protection = ChildProtection(types=["exposure_interaction"], async_mode=True)
+ child_protection = ChildProtection(
+ types=["exposure_interaction"], async_mode=True
+ )
async def dummy_model_callback(prompt):
return prompt
@@ -98,7 +120,9 @@ class TestChildProtection:
assert child_protection.simulated_attacks is not None and isinstance(
child_protection.simulated_attacks, dict
)
- assert child_protection.res is not None and isinstance(child_protection.res, dict)
+ assert child_protection.res is not None and isinstance(
+ child_protection.res, dict
+ )
assert ChildProtectionType.EXPOSURE_INTERACTION in results
assert len(results[ChildProtectionType.EXPOSURE_INTERACTION]) == 1
test_case = results[ChildProtectionType.EXPOSURE_INTERACTION][0]