22
33from importlib .metadata import entry_points
44
5+ import pytest
6+
57from diracx .core .extensions import DiracEntryPoint
68
79
810def test_diracx_resources_entry_point ():
911 """Test that the diracx.resources entry point is properly configured."""
10- # Get all entry points for the diracx.resources group
1112 resources_eps = entry_points ().select (group = DiracEntryPoint .RESOURCES )
1213
13- # Check that find_compatible_platforms entry point exists
1414 find_platforms_ep = None
1515 for ep in resources_eps :
1616 if ep .name == "find_compatible_platforms" :
@@ -22,52 +22,20 @@ def test_diracx_resources_entry_point():
2222 )
2323 assert find_platforms_ep .value == "diracx.core.resources:find_compatible_platforms"
2424
25- # Test that the entry point can be loaded
26- loaded_func = find_platforms_ep .load ()
27- # Check that it's callable
28- assert callable (loaded_func )
29-
30-
31- def test_entry_point_functionality ():
32- """Test that the entry point points to the correct function."""
33- # Get the entry point
34- resources_eps = entry_points ().select (group = DiracEntryPoint .RESOURCES )
35- find_platforms_ep = None
36- for ep in resources_eps :
37- if ep .name == "find_compatible_platforms" :
38- find_platforms_ep = ep
39- break
40-
41- assert find_platforms_ep is not None
42-
43- # Load the function from the entry point
4425 loaded_func = find_platforms_ep .load ()
45-
46- # Verify it's callable
4726 assert callable (loaded_func )
4827
49- # Verify the function has the expected signature and behavior
50- from diracx .core .config import Config
51-
52- test_config = Config .model_validate (
53- {
54- "DIRAC" : {},
55- "Registry" : {},
56- "Operations" : {},
57- "Resources" : {
58- "Computing" : {
59- "OSCompatibility" : {
60- "slc7" : {"slc7" , "centos7" },
61- }
62- }
63- },
64- }
65- )
6628
67- job_platforms = ["slc7" ]
29+ def _all_diracx_entry_points ():
30+ """Yield (group, entry_point) for every diracx.* entry point."""
31+ for group in sorted (entry_points ().groups ):
32+ if not group .startswith ("diracx" ):
33+ continue
34+ for ep in entry_points ().select (group = group ):
35+ yield pytest .param (ep , id = f"{ group } :{ ep .name } " )
6836
69- # Test that the function can be called and returns a list
70- result = loaded_func (job_platforms , test_config )
7137
72- # Verify it returns a list (the exact content may vary due to extensions)
73- assert isinstance (result , list )
38+ @pytest .mark .parametrize ("ep" , _all_diracx_entry_points ())
39+ def test_all_entry_points_loadable (ep ):
40+ """Every registered diracx.* entry point must be importable."""
41+ ep .load ()
0 commit comments