From 4218f8572d8d0b9efdcb0e5e67e6f647d00c130f Mon Sep 17 00:00:00 2001 From: Tejas Shasane Date: Tue, 6 Oct 2026 10:31:39 +0530 Subject: [PATCH] Fix UPC token-only variant selection --- tests/config_reader.py | 5 ++++- tests/test_setup_config.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/tests/config_reader.py b/tests/config_reader.py index a66e960..84a5063 100644 --- a/tests/config_reader.py +++ b/tests/config_reader.py @@ -46,7 +46,10 @@ def get_setup_configs(mode, config=None): variants = product.get("session_variants") if variants is not None: resolved = get_product_config(name, config) - if not resolved["setup"].get("run_session", True): + # Expand variants when either session or token execution is + # enabled. Token-only UPC runs must still reach their variants. + setup = resolved.get("setup", {}) + if not setup.get("run_session", True) and not setup.get("run_token", True): continue variant_config = deepcopy(config) variant_config["products"] = {} diff --git a/tests/test_setup_config.py b/tests/test_setup_config.py index 36c232e..f5b7a74 100644 --- a/tests/test_setup_config.py +++ b/tests/test_setup_config.py @@ -78,3 +78,38 @@ def test_upc_session_selection_and_shared_timing(selected): assert config == original config["products"]["UPC"]["enabled"] = False assert get_setup_configs("session", config) == [] + + +def test_upc_token_only_expands_all_enabled_variants(): + config = { + "setup": {"run_session": True, "run_token": True}, + "products": { + "UPC": { + "enabled": True, + "run_session": False, + "run_token": True, + "token": { + "market_code": "NATIONAL", + "product_type": "UPC", + "product_codes": [], + }, + "session_variants": { + name: { + "enabled": True, + "run_session": False, + "run_token": True, + "token": {"create_product_codes": [f"{name}_TOKEN"]}, + } + for name in ("DAILY", "WEEKLY", "MONTHLY") + }, + } + }, + } + + configs = get_setup_configs("token", config) + + assert [item["product_name"] for item in configs] == [ + "UPC_DAILY", + "UPC_WEEKLY", + "UPC_MONTHLY", + ] -- 2.54.0