Answer stability round 2: 0 🔴, 1 🟡 (0 misread); test loop-claude's DM through the faked HTTP edge instead of the patched dm, and narrow the comment on which stops are DMed
CI / tests (pull_request) Successful in 2m22s

This commit was merged in pull request #523.
This commit is contained in:
2026-11-13 20:48:43 +01:00
parent a55ecc0be6
commit effe6393c0
3 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ def main(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher:
raise
if stop.reason:
say(stop.reason, effects, stdout=not stop.code)
# Every stop but the human's own Ctrl-C and the help is DMed, so a loop left overnight never ends unseen. A loop given no task prints the help.
# Every stop but the human's own Ctrl-C and the help is DMed where the project's config can be read and sets `env-file`, so a loop left overnight never ends unseen. A loop given no task prints the help.
if stop.code != 130 and stop.reason != HELP:
tell(f"loop-claude in {cwd} stopped: {stop.reason}", effects)
return stop.code
-9
View File
@@ -13,7 +13,6 @@ import unittest.mock
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from mattermost_dm.dm import http_json
from loop_effects.effects import run_python, say, system_effects
NOW = 1790000000
@@ -59,14 +58,6 @@ class Said(unittest.TestCase):
self.assertEqual(flushes, [f"{STAMP} hello\n"])
class Dm(unittest.TestCase):
def test_sends_the_text_for_the_project_holding_the_current_directory_with_the_real_http(self):
with unittest.mock.patch("loop_effects.effects.dm", return_value=None) as sent:
self.assertIsNone(system_effects().dm("Which one?"))
sent.assert_called_once_with("Which one?", None, pathlib.Path.home(), http_json)
class LocalTime(unittest.TestCase):
def test_renders_seconds_in_the_machines_zone(self):
# A POSIX zone two hours ahead of UTC, so a time in UTC would read 14:13:20. Cleanups run last in, first out: the zone is restored before time.tzset makes the clock read it again.
+9
View File
@@ -1,3 +1,4 @@
import contextlib
import http.server
import io
import json
@@ -16,6 +17,7 @@ from project_config.test_project_config import configured
from mattermost_dm import dm, main
from failure import Failure
from test_env import isolated_env
from loop_effects.effects import system_effects
TOOL = pathlib.Path(__file__).resolve().parents[1] / "mattermost-dm"
CONFIG = dm.Config("https://chat.example", "secret-token", "lilleman")
@@ -228,6 +230,13 @@ class Dm(Project):
self.assertIsNone(dm.dm("Which one?", str(self.checkout), self.home, server))
self.assertEqual(server.requests[-1], ("POST", "https://chat.example/api/v4/posts", "secret-token", {"channel_id": "channel-id", "message": "Which one?"}))
def test_loop_claudes_dm_posts_the_text_for_the_project_holding_the_current_directory(self):
self.name_env_file("MATTERMOST_URL=https://chat.example\nMATTERMOST_TOKEN=secret-token\nMATTERMOST_RECIPIENT=lilleman\n")
server = mattermost()
with unittest.mock.patch("loop_effects.effects.http_json", server), contextlib.chdir(self.checkout):
self.assertIsNone(system_effects().dm("Which one?"))
self.assertEqual(server.requests[-1], ("POST", "https://chat.example/api/v4/posts", "secret-token", {"channel_id": "channel-id", "message": "Which one?"}))
def test_skips_the_dm_for_a_project_whose_config_names_no_env_file_even_where_the_old_shared_file_exists(self):
(self.home / ".claude").mkdir()
env_file(str(self.home / ".claude"), "MATTERMOST_URL=https://chat.example\nMATTERMOST_TOKEN=other-projects-token\nMATTERMOST_RECIPIENT=lilleman\n", name=".env")