@@ -20,14 +20,14 @@ def _get_links_data(cls):
20
20
if cls ._links_data is None :
21
21
lmfdb_dir = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
22
22
yaml_path = os .path .join (lmfdb_dir , "homepage" , "index_boxes.yaml" )
23
-
23
+
24
24
with open (yaml_path , "r" ) as f :
25
25
boxes = list (yaml .load_all (f , Loader = yaml .FullLoader ))
26
-
26
+
27
27
links = []
28
28
for box_idx , box in enumerate (boxes ):
29
29
box_title = box .get ("title" , f"Box { box_idx + 1 } " )
30
-
30
+
31
31
if "content" in box :
32
32
urls = cls ._parse_links_from_content (box ["content" ])
33
33
for url in urls :
@@ -37,7 +37,7 @@ def _get_links_data(cls):
37
37
"is_external" : url .startswith (('http://' , 'https://' )),
38
38
"is_internal" : url .startswith ('/' ),
39
39
})
40
-
40
+
41
41
cls ._links_data = links
42
42
return cls ._links_data
43
43
@@ -52,9 +52,9 @@ def _test_link(self, link_info):
52
52
url = link_info ["url" ]
53
53
box_title = link_info ["box_title" ]
54
54
homepage = self ._get_homepage ()
55
-
55
+
56
56
# Check that link appears in homepage
57
- self .assertIn (url , homepage ,
57
+ self .assertIn (url , homepage ,
58
58
f"Link { url } from { box_title } not found in homepage" )
59
59
60
60
if link_info ["is_external" ]:
@@ -73,7 +73,7 @@ def test_all_internal_links(self):
73
73
"""Test all internal links found in index_boxes.yaml."""
74
74
links = self ._get_links_data ()
75
75
internal_links = [link for link in links if link ["is_internal" ]]
76
-
76
+
77
77
for link_info in internal_links :
78
78
with self .subTest (url = link_info ["url" ], box = link_info ["box_title" ]):
79
79
self ._test_link (link_info )
@@ -82,23 +82,23 @@ def test_all_external_links(self):
82
82
"""Test all external links found in index_boxes.yaml."""
83
83
links = self ._get_links_data ()
84
84
external_links = [link for link in links if link ["is_external" ]]
85
-
85
+
86
86
for link_info in external_links :
87
87
with self .subTest (url = link_info ["url" ], box = link_info ["box_title" ]):
88
88
self ._test_link (link_info )
89
89
90
90
def test_all_links_by_box (self ):
91
91
"""Test all links grouped by box."""
92
92
links = self ._get_links_data ()
93
-
93
+
94
94
# Group links by box
95
95
boxes = {}
96
96
for link in links :
97
97
box_title = link ["box_title" ]
98
98
if box_title not in boxes :
99
99
boxes [box_title ] = []
100
100
boxes [box_title ].append (link )
101
-
101
+
102
102
for box_title , box_links in boxes .items ():
103
103
with self .subTest (box = box_title ):
104
104
for link_info in box_links :
@@ -118,23 +118,23 @@ def test_method(self):
118
118
for link_info in box_links :
119
119
with self .subTest (url = link_info ["url" ]):
120
120
self ._test_link (link_info )
121
-
121
+
122
122
test_method .__doc__ = f"Test links from box: { box_title } "
123
123
return test_method
124
124
125
125
126
126
# Add individual box tests
127
127
try :
128
128
links = HomePageTest ._get_links_data ()
129
-
129
+
130
130
# Group links by box for dynamic test creation
131
131
boxes = {}
132
132
for link in links :
133
133
box_title = link ["box_title" ]
134
134
if box_title not in boxes :
135
135
boxes [box_title ] = []
136
136
boxes [box_title ].append (link )
137
-
137
+
138
138
# Create test methods for each box
139
139
for box_title , box_links in boxes .items ():
140
140
safe_name = re .sub (r'[^a-zA-Z0-9_]' , '_' , box_title .lower ())
0 commit comments