@@ -1248,3 +1248,37 @@ async def test_get_message_pieces_filters_on_integer_prompt_metadata_async(sqlit
12481248
12491249 assert len (retrieved ) == 1
12501250 assert retrieved [0 ].original_value == "sent"
1251+
1252+
1253+ @pytest .mark .parametrize (
1254+ "kwargs, expected" ,
1255+ [
1256+ ({"property_path" : "$.label" , "value" : "éthique" }, 1 ),
1257+ ({"property_path" : "$.label" , "value" : "ÉTHIQUE" }, 1 ),
1258+ ({"property_path" : "$.label" , "value" : "éth" , "partial_match" : True }, 1 ),
1259+ ({"property_path" : "$.label" , "value" : "éthique" , "case_sensitive" : True }, 0 ),
1260+ ({"property_path" : "$.label" , "value" : "ethique" }, 0 ),
1261+ ({"property_path" : "$.items" , "array_element_path" : "$.name" , "array_to_match" : ["ÜBERWACHUNG" , "fraud" ]}, 1 ),
1262+ ({"property_path" : "$.items" , "array_element_path" : "$.name" , "array_to_match" : ["überwachung" , "missing" ]}, 0 ),
1263+ ],
1264+ )
1265+ async def test_json_match_conditions_fold_non_ascii_case_async (
1266+ sqlite_instance : SQLiteMemory , kwargs : dict [str , object ], expected : int
1267+ ) -> None :
1268+ piece = MessagePiece (
1269+ conversation_id = str (uuid .uuid4 ()),
1270+ role = "assistant" ,
1271+ original_value = "stored" ,
1272+ prompt_metadata = {"label" : "ÉTHIQUE" , "items" : [{"name" : "Überwachung" }, {"name" : "Fraud" }]},
1273+ )
1274+ await sqlite_instance .add_message_pieces_to_memory_async (message_pieces = [piece ])
1275+
1276+ match = (
1277+ sqlite_instance ._get_condition_json_array_match
1278+ if "array_to_match" in kwargs
1279+ else sqlite_instance ._get_condition_json_property_match
1280+ )
1281+ condition = match (json_column = PromptMemoryEntry .prompt_metadata , ** kwargs )
1282+ async with await sqlite_instance .get_session_async () as session :
1283+ rows = (await session .execute (select (PromptMemoryEntry .id ).where (condition ))).all ()
1284+ assert len (rows ) == expected
0 commit comments