Files
DECNET/tests/orchestrator/emailgen/test_threads.py
anti f2b3393669 chore: relicense to AGPL-3.0-or-later and add SPDX headers
Replaces LICENSE (GPLv3 -> AGPLv3) and prepends
`SPDX-License-Identifier: AGPL-3.0-or-later` to every source file
across decnet/, decnet_web/, tests/, scripts/, and tools/.

Rationale: closes the GPLv3 ASP loophole so any party operating a
modified DECNET as a network service must offer their modified
source. Personal copyright (Samuel Paschuan) + inbound=outbound
contributions make a future unilateral relicense infeasible.

- LICENSE: full AGPL-3.0 text (gnu.org/licenses/agpl-3.0.txt)
- COPYRIGHT: project copyright notice
- tools/add_spdx_headers.py: idempotent header injector
  (shebang- and PEP 263-aware)

Touches 1565 source files (.py, .ts, .tsx, .js, .jsx, .css, .sh).
No behavior change; comments only.
2026-05-22 21:04:16 -04:00

63 lines
1.5 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""Thread-chain helpers."""
from __future__ import annotations
from decnet.orchestrator.emailgen.threads import (
ThreadChain,
new_message_id,
new_thread_id,
references_for_reply,
reply_subject,
)
def test_new_thread_id_is_uuid_string():
tid = new_thread_id()
assert len(tid) == 36
assert tid.count("-") == 4
def test_new_message_id_format_with_domain():
mid = new_message_id("example.com")
assert mid.startswith("<") and mid.endswith(">")
assert "@example.com" in mid
def test_new_message_id_handles_blank_domain():
mid = new_message_id(" ")
assert "@localhost" in mid
def test_reply_subject_prepends_re():
assert reply_subject("Q3 budget") == "Re: Q3 budget"
def test_reply_subject_collapses_existing_re():
assert reply_subject("Re: Re: Q3 budget") == "Re: Q3 budget"
assert reply_subject("RE: Q3 budget") == "Re: Q3 budget"
def test_references_for_reply_root_is_empty():
assert references_for_reply(None) == ""
def test_references_for_reply_appends_parent():
chain = ThreadChain(
thread_id="t1",
parent_message_id="<m2@x>",
references=("<m1@x>",),
parent_subject="Re: budget",
)
refs = references_for_reply(chain)
assert refs == "<m1@x> <m2@x>"
def test_references_empty_chain_starts_with_parent_only():
chain = ThreadChain(
thread_id="t1",
parent_message_id="<m1@x>",
references=(),
parent_subject="budget",
)
assert references_for_reply(chain) == "<m1@x>"