tests: write the offered-models list beside every models table fixture
Adds an offered(data_dir, text) helper, called from Core.table() and from each direct models.md write in the store; pops CLAUDE_CODE_ENTRYPOINT in the test env. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3a349a3859
commit
8c4fdf944e
2 files changed
+24
-2
No files matched your search
+12
-1
@@ -59,6 +59,15 @@ def tree():
|
|||||||
REAL_HOME = os.path.expanduser("~")
|
REAL_HOME = os.path.expanduser("~")
|
||||||
|
|
||||||
|
|
||||||
|
def offered(data_dir, text):
|
||||||
|
"""The offered-models list for the current harness, written beside models.md: pick refuses without it."""
|
||||||
|
path = os.path.join(data_dir, "offered", "unknown.txt")
|
||||||
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||||
|
with open(path, "w", encoding="utf-8") as f:
|
||||||
|
f.write("listed %s by harness unknown\n%s" % (time.strftime("%Y-%m-%dT%H:%M:%S"), text))
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
class Core(unittest.TestCase):
|
class Core(unittest.TestCase):
|
||||||
ENFORCE = False
|
ENFORCE = False
|
||||||
|
|
||||||
@@ -83,7 +92,7 @@ class Core(unittest.TestCase):
|
|||||||
self.env = dict(os.environ, HOME=self.tmp, SISI_DATA=self.data, SISI_STATE=os.path.join(self.tmp, "state"),
|
self.env = dict(os.environ, HOME=self.tmp, SISI_DATA=self.data, SISI_STATE=os.path.join(self.tmp, "state"),
|
||||||
SISI_LIB=os.path.join(self.tmp, "lib"), CLAUDE_CONFIG_DIR=os.path.join(self.tmp, "claude"),
|
SISI_LIB=os.path.join(self.tmp, "lib"), CLAUDE_CONFIG_DIR=os.path.join(self.tmp, "claude"),
|
||||||
PYTHONPATH=py + (os.pathsep + os.environ["PYTHONPATH"] if os.environ.get("PYTHONPATH") else ""))
|
PYTHONPATH=py + (os.pathsep + os.environ["PYTHONPATH"] if os.environ.get("PYTHONPATH") else ""))
|
||||||
for name in ("SISI_SESSION_ID", "CLAUDE_ENV_FILE", "XDG_DATA_HOME", "XDG_STATE_HOME", "CODEX_HOME"):
|
for name in ("SISI_SESSION_ID", "CLAUDE_ENV_FILE", "XDG_DATA_HOME", "XDG_STATE_HOME", "CODEX_HOME", "CLAUDE_CODE_ENTRYPOINT"):
|
||||||
self.env.pop(name, None)
|
self.env.pop(name, None)
|
||||||
self.proj = self.project("alpha")
|
self.proj = self.project("alpha")
|
||||||
if not self.ENFORCE: # these tests hold the reminders; tests/test_plan.py holds the denials
|
if not self.ENFORCE: # these tests hold the reminders; tests/test_plan.py holds the denials
|
||||||
@@ -125,6 +134,7 @@ class Core(unittest.TestCase):
|
|||||||
def table(self, text):
|
def table(self, text):
|
||||||
self.write(os.path.join(self.data, "models.md"), text) if os.path.isdir(self.data) else (
|
self.write(os.path.join(self.data, "models.md"), text) if os.path.isdir(self.data) else (
|
||||||
os.makedirs(self.data), self.write(os.path.join(self.data, "models.md"), text))
|
os.makedirs(self.data), self.write(os.path.join(self.data, "models.md"), text))
|
||||||
|
offered(self.data, text)
|
||||||
|
|
||||||
def state(self, sid="s1"):
|
def state(self, sid="s1"):
|
||||||
return json.loads(self.read(self.tmp, "state", "core-sessions", sid + ".json"))
|
return json.loads(self.read(self.tmp, "state", "core-sessions", sid + ".json"))
|
||||||
@@ -2712,6 +2722,7 @@ cli.main(["tick"])
|
|||||||
self.assertEqual(self.read(self.env["SISI_LIB"], "current", "SOURCE").split("\n")[0], src)
|
self.assertEqual(self.read(self.env["SISI_LIB"], "current", "SOURCE").split("\n")[0], src)
|
||||||
self.sisi("learn", "--level", "user", "Always keep what the person wrote")
|
self.sisi("learn", "--level", "user", "Always keep what the person wrote")
|
||||||
self.write(os.path.join(self.data, "models.md"), WORKERS)
|
self.write(os.path.join(self.data, "models.md"), WORKERS)
|
||||||
|
offered(self.data, WORKERS)
|
||||||
self.write(os.path.join(self.data, "retro.jsonl"), '{"gap": "g"}\n')
|
self.write(os.path.join(self.data, "retro.jsonl"), '{"gap": "g"}\n')
|
||||||
keep = {n: self.read(self.data, n) for n in ("models.md", "retro.jsonl", "rules/user.md")}
|
keep = {n: self.read(self.data, n) for n in ("models.md", "retro.jsonl", "rules/user.md")}
|
||||||
self.source("2.0.0")
|
self.source("2.0.0")
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
@@ -24,6 +25,15 @@ HOST = "| sonnet | Anthropic | anthropic | host subagent `sonnet` | ordinary | p
|
|||||||
FALL = "Fallback order: routine: go/qwen-flash; ordinary: sonnet; hard: zai/glm-5.\n"
|
FALL = "Fallback order: routine: go/qwen-flash; ordinary: sonnet; hard: zai/glm-5.\n"
|
||||||
|
|
||||||
|
|
||||||
|
def offered(data_dir, text):
|
||||||
|
"""The offered-models list for the current harness, written beside models.md: pick refuses without it."""
|
||||||
|
path = os.path.join(data_dir, "offered", "unknown.txt")
|
||||||
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||||
|
with open(path, "w", encoding="utf-8") as f:
|
||||||
|
f.write("listed %s by harness unknown\n%s" % (time.strftime("%Y-%m-%dT%H:%M:%S"), text))
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
def tree():
|
def tree():
|
||||||
out = hashlib.sha1()
|
out = hashlib.sha1()
|
||||||
for p in sorted(glob.glob(os.path.join(REPO, "sisi", "*")) + glob.glob(os.path.join(REPO, "canon", "*"))):
|
for p in sorted(glob.glob(os.path.join(REPO, "sisi", "*")) + glob.glob(os.path.join(REPO, "canon", "*"))):
|
||||||
@@ -46,7 +56,7 @@ class ModelsResearch(unittest.TestCase):
|
|||||||
self.env = dict(os.environ, HOME=self.tmp, SISI_DATA=self.data,
|
self.env = dict(os.environ, HOME=self.tmp, SISI_DATA=self.data,
|
||||||
SISI_STATE=os.path.join(self.tmp, "state"), SISI_LIB=os.path.join(self.tmp, "lib"),
|
SISI_STATE=os.path.join(self.tmp, "state"), SISI_LIB=os.path.join(self.tmp, "lib"),
|
||||||
CLAUDE_CONFIG_DIR=os.path.join(self.tmp, "claude"))
|
CLAUDE_CONFIG_DIR=os.path.join(self.tmp, "claude"))
|
||||||
for name in ("SISI_SESSION_ID", "CLAUDE_ENV_FILE", "XDG_DATA_HOME", "XDG_STATE_HOME", "CODEX_HOME"):
|
for name in ("SISI_SESSION_ID", "CLAUDE_ENV_FILE", "XDG_DATA_HOME", "XDG_STATE_HOME", "CODEX_HOME", "CLAUDE_CODE_ENTRYPOINT"):
|
||||||
self.env.pop(name, None)
|
self.env.pop(name, None)
|
||||||
subprocess.run(["git", "init", "-q", self.data], check=True, capture_output=True, stdin=subprocess.DEVNULL)
|
subprocess.run(["git", "init", "-q", self.data], check=True, capture_output=True, stdin=subprocess.DEVNULL)
|
||||||
|
|
||||||
@@ -186,6 +196,7 @@ class ModelsResearch(unittest.TestCase):
|
|||||||
os.makedirs(self.data, exist_ok=True)
|
os.makedirs(self.data, exist_ok=True)
|
||||||
with open(os.path.join(self.data, "models.md"), "w", encoding="utf-8") as f:
|
with open(os.path.join(self.data, "models.md"), "w", encoding="utf-8") as f:
|
||||||
f.write(self.BUSY)
|
f.write(self.BUSY)
|
||||||
|
offered(self.data, self.BUSY)
|
||||||
use = self.in_process(models.plan_use, self.BUSY)[0]
|
use = self.in_process(models.plan_use, self.BUSY)[0]
|
||||||
self.assertEqual((use["plan a"]["5h"], use["plan a"]["week"]), (0.0, 0.125))
|
self.assertEqual((use["plan a"]["5h"], use["plan a"]["week"]), (0.0, 0.125))
|
||||||
out = self.in_process(models.run, [])[1]
|
out = self.in_process(models.run, [])[1]
|
||||||
|
|||||||
Reference in new issue
Block a user