feat: restore source parity and harden agent runtime
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from datetime import datetime
|
||||
|
||||
from online_dev.report_manager.engine.watermark import (
|
||||
build_watermark_payload,
|
||||
resolve_watermark_config,
|
||||
)
|
||||
|
||||
|
||||
def test_resolve_show_time():
|
||||
fixed = datetime(2026, 5, 22, 15, 30, 0)
|
||||
cfg = resolve_watermark_config(
|
||||
{"content": "机密", "showTime": True, "timeFormat": "yyyy-MM-dd"},
|
||||
now=fixed,
|
||||
)
|
||||
assert cfg["content"] == "机密 2026-05-22"
|
||||
|
||||
|
||||
def test_build_payload_disabled():
|
||||
payload = build_watermark_payload(False, {"content": "x"})
|
||||
assert payload["show"] is False
|
||||
assert payload["config"] == {}
|
||||
|
||||
|
||||
def test_build_payload_enabled():
|
||||
payload = build_watermark_payload(True, {"content": "ZQ"}, template_name="报表A")
|
||||
assert payload["show"] is True
|
||||
assert payload["config"]["content"] == "ZQ"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_resolve_show_time()
|
||||
test_build_payload_disabled()
|
||||
test_build_payload_enabled()
|
||||
print("ok")
|
||||
Reference in New Issue
Block a user