@@ -162,17 +162,39 @@ async def test_scenario_3_safe_french_query_allowed(self, content_filter_guardra
162162
163163
164164 @pytest .mark .asyncio
165- async def test_all_scenarios_summary (self ):
166- """Run all scenarios and print summary."""
165+ async def test_pure_conditional_matching (self , content_filter_guardrail ):
166+ """
167+ Test pure conditional matching (identifier + block word, not in always_block_keywords).
168+ This ensures conditional matching works independently of always_block_keywords.
169+ """
170+ # This sentence contains "analyser" (identifier) + "sentiment des salariés" (block word)
171+ # but doesn't match any always_block_keywords
172+ sentence = "Développer un outil pour analyser le sentiment des salariés en continu"
173+ request_data = {"messages" : [{"role" : "user" , "content" : sentence }]}
174+
167175 print (f"\n { '=' * 70 } " )
168- print ("EU AI ACT FRENCH LANGUAGE SUPPORT - 3 SCENARIOS SUMMARY" )
169- print (f"{ '=' * 70 } " )
170- print (f"✓ Scenario 1: Direct prohibited query → BLOCKED ✓" )
171- print (f"✓ Scenario 2: Circumvention attempt → BLOCKED ✓" )
172- print (f"✓ Scenario 3: Safe legitimate query → ALLOWED ✓" )
176+ print ("PURE CONDITIONAL MATCHING TEST" )
173177 print (f"{ '=' * 70 } " )
174- print (f"\n All 3 critical scenarios passed successfully!" )
175- print (f"French language support is working correctly for EU AI Act Article 5.\n " )
178+ print (f"Query: { sentence } " )
179+ print (f"Translation: Develop a tool to analyze employee sentiment continuously" )
180+ print (f"Expected: BLOCK (conditional match: analyser + sentiment des salariés)" )
181+ print (f"{ '=' * 70 } \n " )
182+
183+ # Should raise an exception (blocked by conditional matching)
184+ with pytest .raises (Exception ) as exc_info :
185+ await content_filter_guardrail .apply_guardrail (
186+ inputs = {"texts" : [sentence ]},
187+ request_data = request_data ,
188+ input_type = "request" ,
189+ )
190+
191+ # Verify it's a conditional match, not an always_block match
192+ error_msg = str (exc_info .value )
193+ assert "conditional match" in error_msg .lower (), \
194+ f"Expected conditional match but got: { error_msg } "
195+
196+ print (f"✓ PURE CONDITIONAL MATCHING PASSED" )
197+ print (f" Reason: { exc_info .value } \n " )
176198
177199
178200# Additional edge cases for French language support
0 commit comments