Skip to content

Commit 4622023

Browse files
authored
Update test_attachments.py
1 parent 24db186 commit 4622023

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎tests/test_attachments.py‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,9 @@ def _saved_body(self):
570570
return dummy._conversation_text(messages)
571571

572572
def test_reattach_when_file_exists(self):
573-
from python_agent_harness.tui.commands import CommandMixin
573+
from python_agent_harness.persistence import parse_saved_body
574574

575-
restored = CommandMixin._parse_saved_body(self._saved_body())
575+
restored = parse_saved_body(self._saved_body())
576576
self.assertEqual(len(restored), 2)
577577
user = restored[0]
578578
self.assertIsInstance(user.content, list)
@@ -585,29 +585,29 @@ def test_reattach_when_file_exists(self):
585585
self.assertEqual([t.text for t in texts], ["what is this"])
586586

587587
def test_no_reattach_when_file_gone(self):
588-
from python_agent_harness.tui.commands import CommandMixin
588+
from python_agent_harness.persistence import parse_saved_body
589589

590590
body = self._saved_body()
591591
os.unlink(self.img)
592-
restored = CommandMixin._parse_saved_body(body)
592+
restored = parse_saved_body(body)
593593
user = restored[0]
594594
self.assertIsInstance(user.content, str)
595595
self.assertIn("not available in restored session", user.content)
596596
self.assertIn("what is this", user.content)
597597

598598
def test_no_reattach_when_file_is_not_an_image(self):
599-
from python_agent_harness.tui.commands import CommandMixin
599+
from python_agent_harness.persistence import parse_saved_body
600600

601601
with open(self.img, "w", encoding="utf-8") as f:
602602
f.write("not really a png")
603-
restored = CommandMixin._parse_saved_body(self._saved_body())
603+
restored = parse_saved_body(self._saved_body())
604604
user = restored[0]
605605
self.assertIsInstance(user.content, str)
606606
self.assertIn("not available in restored session", user.content)
607607

608608
def test_url_image_roundtrip(self):
609+
from python_agent_harness.persistence import parse_saved_body
609610
from python_agent_harness.session import Session
610-
from python_agent_harness.tui.commands import CommandMixin
611611

612612
url = "https://example.com/image.jpg"
613613
messages = [
@@ -620,16 +620,16 @@ def test_url_image_roundtrip(self):
620620
),
621621
]
622622
dummy = type("Dummy", (), {"_conversation_text": Session._conversation_text})()
623-
restored = CommandMixin._parse_saved_body(dummy._conversation_text(messages))
623+
restored = parse_saved_body(dummy._conversation_text(messages))
624624
user = restored[0]
625625
self.assertIsInstance(user.content, list)
626626
images = [p for p in user.content if isinstance(p, ImagePart)]
627627
self.assertEqual(len(images), 1)
628628
self.assertEqual(images[0].url, url)
629629

630630
def test_reattach_path_with_comma(self):
631+
from python_agent_harness.persistence import parse_saved_body
631632
from python_agent_harness.session import Session
632-
from python_agent_harness.tui.commands import CommandMixin
633633

634634
img = os.path.join(self.tmpdir, "my, shot.png")
635635
with open(img, "wb") as f:
@@ -644,7 +644,7 @@ def test_reattach_path_with_comma(self):
644644
),
645645
]
646646
dummy = type("Dummy", (), {"_conversation_text": Session._conversation_text})()
647-
restored = CommandMixin._parse_saved_body(dummy._conversation_text(messages))
647+
restored = parse_saved_body(dummy._conversation_text(messages))
648648
user = restored[0]
649649
self.assertIsInstance(user.content, list)
650650
images = [p for p in user.content if isinstance(p, ImagePart)]

0 commit comments

Comments
 (0)