@@ -1212,6 +1212,41 @@ def test_crontab_timezone_conversion_with_negative_offset_and_dst(
1212
1212
"Paris outside window task should be excluded"
1213
1213
)
1214
1214
1215
+ def test_scheduler_valid_hours (self ):
1216
+ """Test the _get_valid_hour_formats method."""
1217
+ # Create an instance of DatabaseScheduler
1218
+ s = self .Scheduler (app = self .app )
1219
+
1220
+ # Get the valid hours list
1221
+ valid_hours = s ._get_valid_hour_formats ()
1222
+
1223
+ # Basic validations
1224
+ # 24 regular hours + 10 zero-padded hours
1225
+ assert len (valid_hours ) == 34
1226
+
1227
+ # Check both regular and zero-padded formats are present
1228
+ assert "0" in valid_hours
1229
+ assert "00" in valid_hours
1230
+ assert "9" in valid_hours
1231
+ assert "09" in valid_hours
1232
+ assert "23" in valid_hours
1233
+
1234
+ # Verify all hours 0-23 are included
1235
+ for hour in range (24 ):
1236
+ assert str (hour ) in valid_hours
1237
+
1238
+ # Verify zero-padded hours 00-09 are included
1239
+ for hour in range (10 ):
1240
+ assert f"{ hour :02d} " in valid_hours
1241
+
1242
+ # Check for duplicates (set should have same length as list)
1243
+ assert len (set (valid_hours )) == len (valid_hours )
1244
+
1245
+ # Verify all entries are valid hour representations
1246
+ for hour_str in valid_hours :
1247
+ hour_value = int (hour_str )
1248
+ assert 0 <= hour_value <= 23
1249
+
1215
1250
1216
1251
@pytest .mark .django_db
1217
1252
class test_models (SchedulerCase ):
0 commit comments