39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from evennia_tools.telemetry import event_log_path, session_meta_path, write_session_metadata
|
|
from evennia_tools.training import WORLD_BASICS_STEPS, example_eval_path, example_trace_path
|
|
|
|
|
|
class TestEvenniaTraining(unittest.TestCase):
|
|
def test_world_basics_sequence_is_stable(self):
|
|
self.assertEqual(
|
|
tuple(step["command"] for step in WORLD_BASICS_STEPS),
|
|
("look", "enter", "workshop", "look", "courtyard", "chapel", "look Book of the Soul"),
|
|
)
|
|
|
|
def test_each_step_has_nonempty_expectations(self):
|
|
for step in WORLD_BASICS_STEPS:
|
|
self.assertTrue(step["expected"])
|
|
|
|
def test_example_paths_land_in_examples_dir(self):
|
|
root = Path("/tmp/repo")
|
|
self.assertEqual(example_trace_path(root).name, "world-basics-trace.example.jsonl")
|
|
self.assertEqual(example_eval_path(root).name, "world-basics-eval.example.json")
|
|
|
|
def test_session_meta_path_suffix(self):
|
|
path = session_meta_path("sess1", "/tmp/evennia-test")
|
|
self.assertEqual(path.name, "sess1.meta.json")
|
|
|
|
def test_write_session_metadata(self):
|
|
with tempfile.TemporaryDirectory() as td:
|
|
path = write_session_metadata("sess2", {"kind": "world"}, td)
|
|
self.assertTrue(path.exists())
|
|
self.assertIn("sess2", path.read_text())
|
|
self.assertIn(str(event_log_path("sess2", td)), path.read_text())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|