test(core): extend coverage — console, errors, log, service, time, benchmark
Add missing test modules for previously untested core areas: - console: ForegroundColorEnum, BackgroundColorEnum, Console methods - errors: dependency_error, module_dependency_error - log: LogLevel ordering/values, LogSettings, Logger (should_log, format, file write, fatal) - service: HostedService, StartupTask, CronjobABC (start/stop/loop/task cancellation) - time: TimeFormatSettings properties and setters - utils: Benchmark.time / .memory / .all call-count and output Also fix existing test files: environment cleanup, cron exception specificity, json_processor kwargs bug doc, configuration_model_abc to_dict bug doc. All 199 tests pass, black clean. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -56,5 +56,5 @@ def test_custom_start_time():
|
||||
|
||||
|
||||
def test_invalid_cron_expression():
|
||||
with pytest.raises(Exception):
|
||||
with pytest.raises((ValueError, KeyError)):
|
||||
Cron("invalid expression")
|
||||
|
||||
44
test/core/time/time_format_settings_test.py
Normal file
44
test/core/time/time_format_settings_test.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import pytest
|
||||
from cpl.core.time.time_format_settings import TimeFormatSettings
|
||||
|
||||
|
||||
def test_defaults_are_none():
|
||||
s = TimeFormatSettings()
|
||||
assert s.date_format is None
|
||||
assert s.time_format is None
|
||||
assert s.date_time_format is None
|
||||
assert s.date_time_log_format is None
|
||||
|
||||
|
||||
def test_constructor_sets_all_fields():
|
||||
s = TimeFormatSettings(
|
||||
date_format="%Y-%m-%d",
|
||||
time_format="%H:%M:%S",
|
||||
date_time_format="%Y-%m-%d %H:%M:%S",
|
||||
date_time_log_format="%Y-%m-%d %H:%M:%S.%f",
|
||||
)
|
||||
assert s.date_format == "%Y-%m-%d"
|
||||
assert s.time_format == "%H:%M:%S"
|
||||
assert s.date_time_format == "%Y-%m-%d %H:%M:%S"
|
||||
assert s.date_time_log_format == "%Y-%m-%d %H:%M:%S.%f"
|
||||
|
||||
|
||||
def test_setters_update_values():
|
||||
s = TimeFormatSettings()
|
||||
s.date_format = "%d/%m/%Y"
|
||||
s.time_format = "%I:%M %p"
|
||||
s.date_time_format = "%d/%m/%Y %I:%M %p"
|
||||
s.date_time_log_format = "%d/%m/%Y %H:%M:%S.%f"
|
||||
assert s.date_format == "%d/%m/%Y"
|
||||
assert s.time_format == "%I:%M %p"
|
||||
assert s.date_time_format == "%d/%m/%Y %I:%M %p"
|
||||
assert s.date_time_log_format == "%d/%m/%Y %H:%M:%S.%f"
|
||||
|
||||
|
||||
def test_partial_construction():
|
||||
# TimeFormatSettings uses constructor args, not option()/from_src()
|
||||
s = TimeFormatSettings(date_format="%Y/%m/%d")
|
||||
assert s.date_format == "%Y/%m/%d"
|
||||
assert s.time_format is None
|
||||
assert s.date_time_format is None
|
||||
assert s.date_time_log_format is None
|
||||
Reference in New Issue
Block a user