Initial import of NLProg
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from nlprog.run_log import list_run_logs, load_run_log, write_run_log
|
||||
|
||||
|
||||
class Event:
|
||||
def __init__(self, kind, message):
|
||||
self.kind = kind
|
||||
self.message = message
|
||||
|
||||
|
||||
class RunLogTests(unittest.TestCase):
|
||||
def test_write_list_and_load_latest_log(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
path = write_run_log(root, "task", "done", [Event("final", "done")], "2026-01-01T00:00:00")
|
||||
self.assertTrue(path.exists())
|
||||
logs = list_run_logs(root)
|
||||
self.assertEqual(logs, [path])
|
||||
loaded_path, data = load_run_log(root, "latest")
|
||||
self.assertEqual(loaded_path, path)
|
||||
self.assertEqual(data["task"], "task")
|
||||
self.assertEqual(data["final"], "done")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user