@@ -224,7 +224,13 @@ def test_context_in_segment(
224224
225225@pytest .mark .parametrize (
226226 "segment_split_value, identity_hashed_percentage, expected_result" ,
227- ((10 , 1 , True ), (100 , 50 , True ), (0 , 1 , False ), (10 , 20 , False )),
227+ (
228+ (10 , 1 , True ),
229+ (100 , 50 , True ),
230+ (0 , 1 , False ),
231+ (10 , 20 , False ),
232+ ("invalid" , 100 , False ),
233+ ),
228234)
229235def test_context_in_segment_percentage_split (
230236 mocker : MockerFixture ,
@@ -270,6 +276,49 @@ def test_context_in_segment_percentage_split(
270276 assert result == expected_result
271277
272278
279+ def test_context_in_segment_percentage_split__no_identity__returns_expected (
280+ mocker : MockerFixture ,
281+ context : EvaluationContext ,
282+ ) -> None :
283+ # Given
284+ del context ["identity" ]
285+
286+ segment_context : SegmentContext = {
287+ "key" : "1" ,
288+ "name" : "% split" ,
289+ "rules" : [
290+ {
291+ "type" : constants .ALL_RULE ,
292+ "conditions" : [],
293+ "rules" : [
294+ {
295+ "type" : constants .ALL_RULE ,
296+ "conditions" : [
297+ {
298+ "operator" : constants .PERCENTAGE_SPLIT ,
299+ "property" : "" ,
300+ "value" : "10" ,
301+ }
302+ ],
303+ "rules" : [],
304+ }
305+ ],
306+ }
307+ ],
308+ }
309+
310+ mock_get_hashed_percentage = mocker .patch (
311+ "flag_engine.segments.evaluator.get_hashed_percentage_for_object_ids"
312+ )
313+
314+ # When
315+ result = is_context_in_segment (context = context , segment_context = segment_context )
316+
317+ # Then
318+ mock_get_hashed_percentage .assert_not_called ()
319+ assert result is False
320+
321+
273322def test_context_in_segment_percentage_split__trait_value__calls_expected (
274323 mocker : MockerFixture ,
275324 context : EvaluationContext ,
0 commit comments