Skip to content

Commit 2b0b5fd

Browse files
committed
test(gubbins): add test to verify with_config_repo uses extension Config
This test validates that the with_config_repo fixture uses extension-aware Config discovery. It checks that the JSON file contains GubbinsSpecificInfo in user configs, which only exists if gubbins Config was used for serialization. The test fails without the fix in diracx-testing and passes with it.
1 parent 83d943b commit 2b0b5fd

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

extensions/gubbins/gubbins-core/tests/test_config.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,33 @@ def test_remote_git_config_source(monkeypatch):
3636
assert isinstance(modified, datetime.datetime)
3737
result = remote_conf.read_raw(hexsha, modified)
3838
assert isinstance(result, Config)
39+
40+
41+
def test_with_config_repo_uses_gubbins_config(with_config_repo):
42+
"""Verify with_config_repo fixture uses gubbins Config, not base Config.
43+
44+
The with_config_repo fixture must use select_from_extension() to discover
45+
the Config class, so extensions like gubbins can add fields to the schema.
46+
47+
Before the fix (DIRACGrid/diracx#727), the fixture directly imported Config
48+
from diracx.core.config, bypassing the extension system. This caused the
49+
fixture to serialize config using base UserConfig (without GubbinsSpecificInfo),
50+
so the JSON file wouldn't contain gubbins-specific fields.
51+
52+
This test reads the raw JSON to verify it contains GubbinsSpecificInfo,
53+
which proves the fixture used gubbins Config for serialization.
54+
"""
55+
import json
56+
57+
# Read the raw JSON file created by the fixture
58+
config_file = with_config_repo / "default.yml"
59+
raw_config = json.loads(config_file.read_text())
60+
61+
# The JSON should contain GubbinsSpecificInfo in user configs
62+
# This field only exists if gubbins Config was used to serialize
63+
for vo_config in raw_config["Registry"].values():
64+
for user_config in vo_config["Users"].values():
65+
assert "GubbinsSpecificInfo" in user_config, (
66+
"GubbinsSpecificInfo not found in JSON - fixture may not be using "
67+
"extension-aware Config discovery"
68+
)

0 commit comments

Comments
 (0)