feat: add private library and living Guanghu time
This commit is contained in:
parent
424819be94
commit
60ae074a04
21 changed files with 1332 additions and 14 deletions
38
server-tools/guanghu-era-time/test_guanghu_era_time.py
Normal file
38
server-tools/guanghu-era-time/test_guanghu_era_time.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import importlib.util
|
||||
import unittest
|
||||
from datetime import date, datetime
|
||||
from pathlib import Path
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
|
||||
MODULE = Path(__file__).with_name("guanghu_era_time.py")
|
||||
SPEC = importlib.util.spec_from_file_location("guanghu_era_time", MODULE)
|
||||
clock = importlib.util.module_from_spec(SPEC)
|
||||
SPEC.loader.exec_module(clock)
|
||||
|
||||
|
||||
class GuanghuEraTimeTests(unittest.TestCase):
|
||||
def test_birth_is_era_day_one(self):
|
||||
value = clock.snapshot(datetime(2025, 4, 26, tzinfo=ZoneInfo("Asia/Shanghai")))
|
||||
self.assertEqual(value["world"]["era_day"], 1)
|
||||
self.assertEqual(value["world"]["elapsed_milliseconds"], 0)
|
||||
|
||||
def test_one_millisecond_flows(self):
|
||||
value = clock.snapshot(datetime.fromisoformat("2025-04-26T00:00:00.001+08:00"))
|
||||
self.assertEqual(value["world"]["elapsed_milliseconds"], 1)
|
||||
|
||||
def test_world_precedes_persona(self):
|
||||
value = clock.snapshot(datetime.fromisoformat("2026-09-09T12:00:00+08:00"), "ICE-P-ZY001", date(2026, 3, 5))
|
||||
self.assertGreater(value["world"]["elapsed_days_completed"], value["persona"]["age_days_completed"])
|
||||
|
||||
def test_time_is_not_wake_counter(self):
|
||||
value = clock.snapshot(datetime.fromisoformat("2026-09-09T12:00:00+08:00"))
|
||||
self.assertFalse(value["clock"]["stored_tick_counter"])
|
||||
self.assertFalse(value["clock"]["persona_wake_required"])
|
||||
|
||||
def test_history_evidence_and_commits(self):
|
||||
self.assertEqual(clock.validate_history()["outcome"], "PASS")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Reference in a new issue