11"""Smoke tests for production health monitoring."""
22
33import json
4- import subprocess
54import sys
65from datetime import datetime
76from pathlib import Path
@@ -97,7 +96,9 @@ def test_conference_dates_valid(self, critical_data_files):
9796 if cfp and cfp not in ["TBA" , "Cancelled" , "None" ]:
9897 try :
9998 # Should be in YYYY-MM-DD HH:MM:SS format
100- datetime .strptime (cfp , "%Y-%m-%d %H:%M:%S" )
99+ datetime .strptime (cfp , "%Y-%m-%d %H:%M:%S" ).replace (
100+ tzinfo = datetime .timezone .utc ,
101+ )
101102 except ValueError :
102103 errors .append (f"Conference { i } : Invalid CFP date format: { cfp } " )
103104
@@ -106,7 +107,9 @@ def test_conference_dates_valid(self, critical_data_files):
106107 date_val = conf .get (field )
107108 if date_val and date_val != "TBA" :
108109 try :
109- datetime .strptime (date_val , "%Y-%m-%d" )
110+ datetime .strptime (date_val , "%Y-%m-%d" ).replace (
111+ tzinfo = datetime .timezone .utc ,
112+ )
110113 except ValueError :
111114 errors .append (f"Conference { i } : Invalid { field } date format: { date_val } " )
112115
@@ -124,9 +127,11 @@ def test_required_fields_present(self, critical_data_files):
124127
125128 errors = []
126129 for i , conf in enumerate (conferences [:10 ]): # Check first 10
127- for field in required_fields :
128- if field not in conf :
129- errors .append (f"Conference { i } ({ conf .get ('conference' , 'Unknown' )} ): Missing { field } " )
130+ errors .extend (
131+ f"Conference { i } ({ conf .get ('conference' , 'Unknown' )} ): Missing { field } "
132+ for field in required_fields
133+ if field not in conf
134+ )
130135
131136 assert len (errors ) == 0 , f"Missing required fields: { errors [:5 ]} "
132137
@@ -163,23 +168,6 @@ def test_no_https_violations(self, critical_data_files):
163168
164169 assert len (http_links ) == 0 , f"HTTP links found (should be HTTPS): { http_links [:5 ]} "
165170
166- @pytest .mark .smoke ()
167- @pytest .mark .slow ()
168- def test_jekyll_build_succeeds (self ):
169- """Test that Jekyll can build the site without errors."""
170- project_root = Path (__file__ ).parent .parent .parent
171-
172- # Try to build with test config for speed
173- result = subprocess .run (
174- ["bundle" , "exec" , "jekyll" , "build" , "--config" , "_config.yml,_config.test.yml" , "--quiet" ],
175- cwd = str (project_root ),
176- capture_output = True ,
177- text = True ,
178- timeout = 60 ,
179- )
180-
181- assert result .returncode == 0 , f"Jekyll build failed: { result .stderr } "
182-
183171 @pytest .mark .smoke ()
184172 def test_javascript_files_exist (self ):
185173 """Test that critical JavaScript files exist."""
@@ -271,9 +259,8 @@ def test_timezone_validity(self, critical_data_files):
271259 invalid_tz = []
272260 for conf in conferences [:20 ]: # Check first 20
273261 tz = conf .get ("timezone" )
274- if tz :
275- if not any (tz .startswith (pattern ) for pattern in valid_tz_patterns ):
276- invalid_tz .append (f"{ conf .get ('conference' )} : { tz } " )
262+ if tz and not any (tz .startswith (pattern ) for pattern in valid_tz_patterns ):
263+ invalid_tz .append (f"{ conf .get ('conference' )} : { tz } " )
277264
278265 assert len (invalid_tz ) == 0 , f"Invalid timezones: { invalid_tz } "
279266
@@ -290,7 +277,7 @@ def test_production_endpoints_accessible(self, mock_get, production_url, critica
290277
291278 for path in critical_paths :
292279 url = f"{ production_url } { path } "
293- response = requests .get (url )
280+ response = requests .get (url , timeout = 10 )
294281 assert response .status_code == 200 , f"Failed to access { url } "
295282
296283 @pytest .mark .smoke ()
@@ -349,10 +336,12 @@ def test_no_test_data_in_production(self, critical_data_files):
349336 name = conf .get ("conference" , "" ).lower ()
350337 link = conf .get ("link" , "" ).lower ()
351338
352- for indicator in test_indicators :
353- if indicator .lower () in name or indicator .lower () in link :
354- if "testing" not in name : # Allow legitimate conferences about testing
355- suspicious .append (f"{ conf .get ('conference' )} - { conf .get ('link' )} " )
339+ # Allow legitimate conferences about testing
340+ suspicious .extend (
341+ f"{ conf .get ('conference' )} - { conf .get ('link' )} "
342+ for indicator in test_indicators
343+ if (indicator .lower () in name or indicator .lower () in link ) and "testing" not in name
344+ )
356345
357346 assert len (suspicious ) == 0 , f"Possible test data in production: { suspicious [:5 ]} "
358347
0 commit comments