Files
DECNET/tests/webhook/test_enums.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

51 lines
1.5 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""Unit tests for decnet.webhook.enums — simple→patterns expansion."""
from decnet.webhook.enums import (
SIMPLE_EVENT_PATTERNS,
expand_simple_events,
merge_patterns,
)
def test_simple_event_patterns_covers_three_families():
assert set(SIMPLE_EVENT_PATTERNS) == {
"AttackerDetail",
"DeckyStatus",
"SystemStatus",
}
def test_expand_single_event():
assert expand_simple_events(["AttackerDetail"]) == ["attacker.>"]
def test_expand_multiple_events_concatenates():
out = expand_simple_events(["AttackerDetail", "DeckyStatus"])
assert out == ["attacker.>", "decky.*.state", "decky.*.traffic"]
def test_expand_unknown_event_dropped_silently():
# The Literal type on the router rejects unknowns; this guards against
# programmer error, not user input.
assert expand_simple_events(["NotAThing"]) == []
def test_merge_dedups_overlap():
merged = merge_patterns(["AttackerDetail"], ["attacker.>", "custom.>"])
assert merged == ["attacker.>", "custom.>"]
def test_merge_preserves_order_simple_first():
merged = merge_patterns(["SystemStatus"], ["attacker.>", "decky.*.state"])
assert merged == ["system.>", "attacker.>", "decky.*.state"]
def test_merge_empty_lists_returns_empty():
assert merge_patterns([], []) == []
assert merge_patterns(None, None) == []
def test_merge_drops_empty_strings_and_non_strings():
merged = merge_patterns([], ["", "attacker.>", None]) # type: ignore[list-item]
assert merged == ["attacker.>"]