"""Tests for matrix_io content builders — pure dict shaping, no network.""" import os import sys sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import matrix_io # noqa: E402 def test_reply_content_is_plain_main_timeline_reply(): c = matrix_io.reply_content("hi", "$evt1") rel = c["m.relates_to"] assert rel["m.in_reply_to"]["event_id"] == "$evt1" # a plain reply must NOT carry a thread relation, or it'd land in the thread # instead of the main timeline (the whole point of the nudge). assert "rel_type" not in rel def test_reply_content_without_target_has_no_relation(): c = matrix_io.reply_content("hi", None) assert "m.relates_to" not in c assert c["body"] == "hi" def test_thread_content_stays_threaded(): c = matrix_io.thread_content("hi", "$root1") rel = c["m.relates_to"] assert rel["rel_type"] == "m.thread" assert rel["event_id"] == "$root1" if __name__ == "__main__": fns = [v for k, v in sorted(globals().items()) if k.startswith("test_") and callable(v)] for fn in fns: fn() print(f"ok {fn.__name__}") print(f"\n{len(fns)} passed")