@@ -218,7 +218,7 @@ def test_context_in_segment(
218218 "segment_split_value, identity_hashed_percentage, expected_result" ,
219219 ((10 , 1 , True ), (100 , 50 , True ), (0 , 1 , False ), (10 , 20 , False )),
220220)
221- def test_identity_in_segment_percentage_split (
221+ def test_context_in_segment_percentage_split (
222222 mocker : MockerFixture ,
223223 context : EvaluationContext ,
224224 segment_split_value : int ,
@@ -246,6 +246,36 @@ def test_identity_in_segment_percentage_split(
246246 assert result == expected_result
247247
248248
249+ def test_context_in_segment_percentage_split__trait_value__calls_expected (
250+ mocker : MockerFixture ,
251+ context : EvaluationContext ,
252+ ) -> None :
253+ # Given
254+ assert context ["identity" ] is not None
255+ context ["identity" ]["traits" ]["custom_trait" ] = "custom_value"
256+ percentage_split_condition = SegmentConditionModel (
257+ operator = constants .PERCENTAGE_SPLIT ,
258+ value = "10" ,
259+ property_ = "custom_trait" ,
260+ )
261+ rule = SegmentRuleModel (
262+ type = constants .ALL_RULE , conditions = [percentage_split_condition ]
263+ )
264+ segment = SegmentModel (id = 1 , name = "% split" , rules = [rule ])
265+
266+ mock_get_hashed_percentage = mocker .patch (
267+ "flag_engine.segments.evaluator.get_hashed_percentage_for_object_ids"
268+ )
269+ mock_get_hashed_percentage .return_value = 1
270+
271+ # When
272+ result = is_context_in_segment (context = context , segment = segment )
273+
274+ # Then
275+ mock_get_hashed_percentage .assert_called_once_with ([segment .id , "custom_value" ])
276+ assert result
277+
278+
249279@pytest .mark .parametrize (
250280 "operator, property_, expected_result" ,
251281 (
0 commit comments