Skip to content

Commit 3b908c9

Browse files
committed
Make CMAB flag optional in decide-all test with ENABLED_FLAGS_ONLY
When using ENABLED_FLAGS_ONLY, CMAB flag with 'off' variation (enabled=false) gets filtered out. The test now handles this case gracefully by making the CMAB flag optional and only validating it if present.
1 parent e55bd21 commit 3b908c9

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

tests/acceptance/test_acceptance/test_cmab.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,20 @@ def test_cmab_decide_all_includes_cmab_flag(session_obj):
303303
assert resp.status_code == 200
304304
assert isinstance(results, list), "DecideAll should return a list"
305305

306-
# Find the CMAB flag in results
306+
# Find the CMAB flag in results (may not be present if variation is "off" with ENABLED_FLAGS_ONLY)
307307
cmab_result = None
308308
for result in results:
309309
if result["flagKey"] == CMAB_FLAG_KEY:
310310
cmab_result = result
311311
break
312312

313-
assert cmab_result is not None, f"CMAB flag '{CMAB_FLAG_KEY}' not found in DecideAll response"
314-
assert cmab_result["ruleKey"] == CMAB_EXPERIMENT_KEY
315-
assert cmab_result["variationKey"] in ["on", "off"]
313+
# CMAB flag may not be in response when using ENABLED_FLAGS_ONLY if variation is "off" (enabled=false)
314+
# If present, verify it's valid
315+
if cmab_result is not None:
316+
assert cmab_result["ruleKey"] == CMAB_EXPERIMENT_KEY
317+
assert cmab_result["variationKey"] in ["on", "off"]
318+
# When present in ENABLED_FLAGS_ONLY response, it must be enabled
319+
assert cmab_result.get("enabled") is True, "CMAB flag should be enabled when present in ENABLED_FLAGS_ONLY response"
316320

317321

318322
def test_cmab_with_multiple_keys(session_obj):

0 commit comments

Comments
 (0)