@@ -485,3 +485,47 @@ def test_check_annotations_changed():
485485 }
486486 mock_new_annotations = {"boo" : 456 , "far" : 789 }
487487 assert check_annotations_changed (mock_bundle_annotations , mock_new_annotations )
488+
489+
490+ def test_from_synapse_annotations__boolean_mixed_case ():
491+ """Test that boolean values with random mixed cases are correctly parsed"""
492+ # Test various mixed case combinations of 'true' and 'false'
493+ raw_annotations = {
494+ "id" : "syn123" ,
495+ "etag" : "7bdb83e9-a50a-46e4-987a-4962559f090f" ,
496+ "annotations" : {
497+ "bool1" : {"type" : "BOOLEAN" , "value" : ["True" ]},
498+ "bool2" : {"type" : "BOOLEAN" , "value" : ["TRUE" ]},
499+ "bool3" : {"type" : "BOOLEAN" , "value" : ["true" ]},
500+ "bool4" : {"type" : "BOOLEAN" , "value" : ["TrUe" ]},
501+ "bool5" : {"type" : "BOOLEAN" , "value" : ["False" ]},
502+ "bool6" : {"type" : "BOOLEAN" , "value" : ["FALSE" ]},
503+ "bool7" : {"type" : "BOOLEAN" , "value" : ["false" ]},
504+ "bool8" : {"type" : "BOOLEAN" , "value" : ["FaLsE" ]},
505+ "bool9" : {
506+ "type" : "BOOLEAN" ,
507+ "value" : ["true" , "FALSE" , "TrUe" , "false" ],
508+ },
509+ },
510+ }
511+
512+ result = from_synapse_annotations (raw_annotations )
513+
514+ # All variations of 'true' should be parsed as True
515+ assert result ["bool1" ] == [True ]
516+ assert result ["bool2" ] == [True ]
517+ assert result ["bool3" ] == [True ]
518+ assert result ["bool4" ] == [True ]
519+
520+ # All variations of 'false' should be parsed as False
521+ assert result ["bool5" ] == [False ]
522+ assert result ["bool6" ] == [False ]
523+ assert result ["bool7" ] == [False ]
524+ assert result ["bool8" ] == [False ]
525+
526+ # Mixed list should be parsed correctly
527+ assert result ["bool9" ] == [True , False , True , False ]
528+
529+ # Verify id and etag are preserved
530+ assert result .id == "syn123"
531+ assert result .etag == "7bdb83e9-a50a-46e4-987a-4962559f090f"
0 commit comments