@@ -505,106 +505,3 @@ def test_config_403(session_override_sdk_key):
505505 'rechecking SDK key), status code: 403 Forbidden'
506506
507507 resp .raise_for_status ()
508-
509-
510- def test_config_includes_holdouts (session_obj ):
511- """
512- Test that the config endpoint includes the holdouts field.
513- Validates the holdouts structure is present even if empty.
514- :param session_obj: session object
515- """
516- resp = create_and_validate_request_and_response (ENDPOINT_CONFIG , 'get' , session_obj )
517-
518- assert resp .status_code == 200
519- resp .raise_for_status ()
520-
521- config = resp .json ()
522-
523- # Verify holdouts field exists
524- assert 'holdouts' in config , "Config response should include 'holdouts' field"
525-
526- # Verify it's a list
527- assert isinstance (config ['holdouts' ], list ), "Holdouts should be a list"
528-
529- # Current datafile has no holdouts, so should be empty
530- # When datafiles with holdouts are added, this test can be extended
531- # to validate holdout structure (id, key, audiences, variationsMap)
532- assert config ['holdouts' ] == [], "Current datafile should have no holdouts"
533-
534-
535- def validate_holdout_structure (holdout ):
536- """
537- Helper function to validate a single holdout object structure.
538- :param holdout: holdout object to validate
539- """
540- # Verify required fields exist
541- assert 'id' in holdout , "Holdout should have 'id' field"
542- assert 'key' in holdout , "Holdout should have 'key' field"
543- assert 'audiences' in holdout , "Holdout should have 'audiences' field"
544- assert 'variationsMap' in holdout , "Holdout should have 'variationsMap' field"
545-
546- # Verify field types
547- assert isinstance (holdout ['id' ], str ), "Holdout id should be a string"
548- assert isinstance (holdout ['key' ], str ), "Holdout key should be a string"
549- assert isinstance (holdout ['audiences' ], str ), "Holdout audiences should be a string"
550- assert isinstance (holdout ['variationsMap' ], dict ), "Holdout variationsMap should be a dict"
551-
552- # Verify variationsMap contains valid variation objects
553- for variation_key , variation in holdout ['variationsMap' ].items ():
554- assert isinstance (variation_key , str ), "Variation key should be a string"
555- assert 'id' in variation , "Variation should have 'id' field"
556- assert 'key' in variation , "Variation should have 'key' field"
557- assert 'featureEnabled' in variation , "Variation should have 'featureEnabled' field"
558- assert 'variablesMap' in variation , "Variation should have 'variablesMap' field"
559-
560- assert isinstance (variation ['id' ], str ), "Variation id should be a string"
561- assert isinstance (variation ['key' ], str ), "Variation key should be a string"
562- assert isinstance (variation ['featureEnabled' ], bool ), "Variation featureEnabled should be a bool"
563- assert isinstance (variation ['variablesMap' ], dict ), "Variation variablesMap should be a dict"
564-
565-
566- def test_config_with_holdouts (session_override_sdk_key_holdouts ):
567- """
568- Test that the config endpoint properly returns holdout data when the datafile contains holdouts.
569- This test validates the full structure of holdouts including id, key, audiences, and variationsMap.
570- :param session_override_sdk_key_holdouts: session object with holdouts SDK key
571- """
572- resp = create_and_validate_request_and_response (ENDPOINT_CONFIG , 'get' , session_override_sdk_key_holdouts )
573-
574- assert resp .status_code == 200
575- resp .raise_for_status ()
576-
577- config = resp .json ()
578-
579- # Verify holdouts field exists and is a list
580- assert 'holdouts' in config , "Config response should include 'holdouts' field"
581- assert isinstance (config ['holdouts' ], list ), "Holdouts should be a list"
582-
583- # Verify we have holdouts data (holdouts_datafile has 4 holdouts)
584- assert len (config ['holdouts' ]) == 4 , f"Expected 4 holdouts, got { len (config ['holdouts' ])} "
585-
586- # Validate each holdout structure
587- for holdout in config ['holdouts' ]:
588- validate_holdout_structure (holdout )
589-
590- # Verify specific holdout keys are present
591- holdout_keys = {h ['key' ] for h in config ['holdouts' ]}
592- expected_keys = {'holdout_3' , 'holdout_5' , 'holdouts_4' , 'holdout_6' }
593- assert holdout_keys == expected_keys , f"Expected holdout keys { expected_keys } , got { holdout_keys } "
594-
595- # Verify holdout IDs are present
596- holdout_ids = {h ['id' ] for h in config ['holdouts' ]}
597- expected_ids = {'1673112' , '1673113' , '1673114' , '1673115' }
598- assert holdout_ids == expected_ids , f"Expected holdout IDs { expected_ids } , got { holdout_ids } "
599-
600- # Verify each holdout has the dummy variation
601- for holdout in config ['holdouts' ]:
602- assert 'off' in holdout ['variationsMap' ], f"Holdout { holdout ['key' ]} should have 'off' variation"
603- off_variation = holdout ['variationsMap' ]['off' ]
604- assert off_variation ['id' ] == '$opt_dummy_variation_id' , "Off variation should have dummy ID"
605- assert off_variation ['featureEnabled' ] is False , "Off variation should have featureEnabled=False"
606-
607- # Verify audiences are properly formatted
608- for holdout in config ['holdouts' ]:
609- # Audiences should be a non-empty string containing audience information
610- assert len (holdout ['audiences' ]) > 0 , f"Holdout { holdout ['key' ]} should have audiences"
0 commit comments