message / chat: output improvements
This commit is contained in:
@@ -804,3 +804,27 @@ class MessageRenameTagsTestCase(CmmTestCase):
|
||||
self.message.rename_tags({(Tag('atag1'), Tag('atag2')), (Tag('btag2'), Tag('btag3'))})
|
||||
self.assertIsNotNone(self.message.tags)
|
||||
self.assertSetEqual(self.message.tags, {Tag('atag2'), Tag('btag3')}) # type: ignore [arg-type]
|
||||
|
||||
|
||||
class MessageToStrTestCase(CmmTestCase):
|
||||
def setUp(self) -> None:
|
||||
self.message = Message(Question('This is a question.'),
|
||||
Answer('This is an answer.'),
|
||||
tags={Tag('atag1'), Tag('btag2')},
|
||||
file_path=pathlib.Path('/tmp/foo/bla'))
|
||||
|
||||
def test_to_str(self) -> None:
|
||||
expected_output = f"""{Question.txt_header}
|
||||
This is a question.
|
||||
{Answer.txt_header}
|
||||
This is an answer."""
|
||||
self.assertEqual(self.message.to_str(), expected_output)
|
||||
|
||||
def test_to_str_with_tags_and_file(self) -> None:
|
||||
expected_output = f"""{TagLine.prefix} atag1 btag2
|
||||
FILE: /tmp/foo/bla
|
||||
{Question.txt_header}
|
||||
This is a question.
|
||||
{Answer.txt_header}
|
||||
This is an answer."""
|
||||
self.assertEqual(self.message.to_str(with_tags=True, with_file=True), expected_output)
|
||||
|
||||
Reference in New Issue
Block a user