Sensitive: default deny, allow when sensitive_ok.
| 38 | |
| 39 | |
| 40 | class TestPolicySensitiveGating: |
| 41 | """Sensitive: default deny, allow when sensitive_ok.""" |
| 42 | |
| 43 | def test_sensitive_filtered_by_default(self): |
| 44 | engine = PolicyEngine() |
| 45 | hits = [_make_hit("ad-ok", 0.9), _make_hit("ad-sens", 0.8, sensitive=True)] |
| 46 | constraints = MatchConstraints() |
| 47 | placement = PlacementContext() |
| 48 | result = engine.apply(hits, constraints, placement) |
| 49 | ids = [h.ad_id for h in result] |
| 50 | assert "ad-ok" in ids |
| 51 | assert "ad-sens" not in ids |
| 52 | |
| 53 | def test_sensitive_allowed_when_opted_in(self): |
| 54 | engine = PolicyEngine() |
| 55 | hits = [_make_hit("ad-sens", 0.8, sensitive=True)] |
| 56 | constraints = MatchConstraints(sensitive_ok=True) |
| 57 | placement = PlacementContext() |
| 58 | result = engine.apply(hits, constraints, placement) |
| 59 | assert len(result) == 1 |
| 60 | assert result[0].ad_id == "ad-sens" |
| 61 | |
| 62 | |
| 63 | class TestPolicyAgeRestrictedGating: |
nothing calls this directly
no outgoing calls
no test coverage detected