from types import SimpleNamespace import pytest from tests.conftest import _get_run_prefix, _setup_item_prefix, get_run_id @pytest.mark.parametrize("path,product,expected", [ ("tests/setup/test_combined_setup.py", "IDAS", "IDAS_SESSION_TOKEN"), ("tests/setup/test_combined_setup.py", "RTM", "RTM_SESSION_TOKEN"), ("tests/setup/tokens/test_trading_token.py", "RTM", "RTM_TOKEN"), ("tests/setup/sessions/test_session.py", "RTM", "RTM_SESSION"), ]) def test_setup_artifacts_use_collected_product_and_flow(path, product, expected): item = SimpleNamespace(nodeid=f"{path}::test[{product}]", callspec=SimpleNamespace( params={"config": {"product_name": product}}, )) assert _setup_item_prefix(item) == expected @pytest.mark.parametrize("path", ["tests/setup", "tests\\setup", "tests/setup/test_combined_setup.py"]) def test_setup_report_does_not_use_regression_config(path): config = SimpleNamespace(invocation_params=SimpleNamespace(args=(path, "-k", "RTM"))) assert _get_run_prefix(config) == "PXIL_SETUP" def test_mixed_run_ids_are_cached_separately(tmp_path, monkeypatch): monkeypatch.chdir(tmp_path) (tmp_path / "reports/screenshots/RTM_TOKEN_004").mkdir(parents=True) config = SimpleNamespace() assert get_run_id(config, "RTM_TOKEN") == "RTM_TOKEN_005" assert get_run_id(config, "IDAS_SESSION_TOKEN") == "IDAS_SESSION_TOKEN_001" assert get_run_id(config, "RTM_TOKEN") == "RTM_TOKEN_005"