From 11af9a96df349d547c0cf68b797b285bc209d6a8 Mon Sep 17 00:00:00 2001 From: Kenneth Bruskiewicz Date: Tue, 15 Sep 2026 18:33:52 -0700 Subject: [PATCH] Separate runtime configuration and live-provider test changes --- tests/conftest.py | 15 +++++++++++++++ tests/test_config.py | 9 +-------- tests/test_node_annotator.py | 14 ++++++++++++-- 3 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..f9b634c --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,15 @@ +"""Shared isolation for tests that use TCT's runtime configuration.""" + +from collections.abc import Iterator + +import pytest + +from TCT.config import configure, reset_config + + +@pytest.fixture(autouse=True) +def isolated_runtime_config() -> Iterator[None]: + """Give every test an explicit runtime independent of ambient state.""" + configure(environment="prod") + yield + reset_config() diff --git a/tests/test_config.py b/tests/test_config.py index 5068119..fd26c1c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -9,14 +9,6 @@ ) from TCT.translator_kpinfo import _select_provider_url - -@pytest.fixture(autouse=True) -def clean_runtime_config(): - reset_config() - yield - reset_config() - - def test_prod_ci_and_test_endpoint_resolution(): prod = RuntimeConfig(environment="prod") ci = RuntimeConfig(environment="ci") @@ -52,6 +44,7 @@ def test_environment_variable_selects_ci(monkeypatch): def test_ci_is_the_default_environment(monkeypatch): monkeypatch.delenv("TCT_ENVIRONMENT", raising=False) + reset_config() assert RuntimeConfig().environment == "ci" assert load_config().environment == "ci" diff --git a/tests/test_node_annotator.py b/tests/test_node_annotator.py index daa4135..79576ff 100644 --- a/tests/test_node_annotator.py +++ b/tests/test_node_annotator.py @@ -31,8 +31,18 @@ def use_node_annotator_prod(): 'curie': 'CHEBI:15377', 'expected': { 'query': 'CHEBI:15377', - 'boxed_warning': True, - 'sections': ['aeolus', 'chebi', 'chembl', 'clinical_approval', 'clinical_trials', 'drugbank', 'ndc', 'pubchem', 'unichem', 'unii'], + # Warning and clinical approval/trial fields depend on volatile + # upstream providers and are not part of the stable contract. + 'sections': [ + 'aeolus', + 'chebi', + 'chembl', + 'drugbank', + 'ndc', + 'pubchem', + 'unichem', + 'unii', + ], 'chembl.availability_type': 2, }, },