test: exercise compact parent projection
This commit is contained in:
1 parent
df35836b75
commit
89dbaec6f5
1 file changed
+6
-14
@@ -599,20 +599,12 @@ def test_session_model_parent_session_id():
|
|||||||
|
|
||||||
|
|
||||||
def test_session_compact_includes_parent():
|
def test_session_compact_includes_parent():
|
||||||
"""Verify compact() includes parent_session_id."""
|
"""Verify compact() exposes a fork's parent and omits it for root sessions."""
|
||||||
src = _read('api/models.py')
|
fork = routes.Session(session_id="fork-1", parent_session_id="parent-1")
|
||||||
# Find the compact method and scan its full body for parent_session_id.
|
assert fork.compact()["parent_session_id"] == "parent-1"
|
||||||
# PR #1591 (May 2026) added a has_pending_user_message recompute block at
|
|
||||||
# the top of compact() which pushed the parent_session_id field beyond a
|
root = routes.Session(session_id="root-1")
|
||||||
# 1500-char window — widen the scan to 3000 chars to cover the full
|
assert "parent_session_id" not in root.compact()
|
||||||
# return-dict body without re-tightening every time compact() grows.
|
|
||||||
# compact() accepts optional projection flags on separate lines; match the
|
|
||||||
# method name and first parameter without pinning formatting.
|
|
||||||
compact_def_match = re.search(r"def compact\(\s*self", src)
|
|
||||||
assert compact_def_match, "Could not find compact() method"
|
|
||||||
snippet = src[compact_def_match.start():compact_def_match.start() + 3500]
|
|
||||||
assert "'parent_session_id'" in snippet, \
|
|
||||||
"compact() should include parent_session_id"
|
|
||||||
|
|
||||||
|
|
||||||
def test_session_metadata_fields_includes_parent():
|
def test_session_metadata_fields_includes_parent():
|
||||||
|
|||||||
Reference in new issue
Block a user