Repository navigation
Expand file tree
/
Copy pathtest_codex_patch_scope.py
More file actions
39 lines (32 loc) · 1.81 KB
/
Copy pathtest_codex_patch_scope.py
File metadata and controls
39 lines (32 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright (c) 2026 Firefly Software Solutions Inc.
# SPDX-License-Identifier: Apache-2.0
import json
import unittest
from tests.test_readonly_attribution import CodexOverlap
from tests.test_codex_launch import TANK
from devkit import hooks
from devkit import progress as pg
class CodexPatchScopeTests(CodexOverlap, unittest.TestCase):
def verdict(self, patch, agent="codex"):
# the scope advice for a member's patch, None when it has none
return " ".join(hooks._scope_advice(agent, {
"session_id": self.sid, "agent_id": TANK, "tool_name": "apply_patch", "cwd": "/repo",
"tool_input": {"input": patch}})) or None
def test_patch_content_is_not_a_target_and_target_spaces_are_preserved(self):
pg.assign("api", "Tank", scope="api/with space.py", why="exact file contract")
patch = ("*** Begin Patch\n*** Add File: api/with space.py\n"
"+fixture = '''\n+*** Delete File: outside.py\n+'''\n*** End Patch\n")
self.assertIsNone(self.verdict(patch))
legacy = dict(pg.load_run("codex", self.sid), agent="claude")
pg.run_path("claude", self.sid).write_text(json.dumps(legacy))
self.assertIn("outside", self.verdict(patch, "claude") or "")
def test_move_destination_must_belong_to_the_member_scope(self):
patch = ("*** Begin Patch\n*** Update File: api/x.py\n*** Move to: outside.py\n"
"@@\n-old\n+new\n*** End Patch\n")
self.assertIn("outside", self.verdict(patch) or "")
self.assertIsNone(self.verdict(patch.replace("outside.py", "api/new name.py")))
legacy = dict(pg.load_run("codex", self.sid), agent="claude")
pg.run_path("claude", self.sid).write_text(json.dumps(legacy))
self.assertIsNone(self.verdict(patch, "claude"))
if __name__ == "__main__":
unittest.main()