bridge/bridge.py: parse_trigger(body) → (is_trigger, quick); accepts exactly '!testme' (cold, default) and '!testme --quick' (opt-in fast lane), rejects '!testmexyz'/'!testme foo'/etc. Threaded through both poll + webhook paths and process_testme → trigger_build adds the CCCI_QUICK=1 Drone param (auto-exposed to run_recipe_ci). PR comment labels a quick run lower-confidence. .drone.yml echoes quick=. +3 unit tests (incl. the !testmexyz negative). 64 unit pass. WC7: default !testme stays full cold; --quick opt-in, never gates merge. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
"""Unit tests for the bridge's `!testme` / `!testme --quick` trigger parser (WC7 + D1).
|
|
|
|
Pure: imports bridge/bridge.py (stdlib-only, no side effects at import — main() is __main__-guarded).
|
|
Locks the two accepted forms and the must-NOT-trigger cases the Adversary probes (`!testmexyz`, etc.).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
|
|
# bridge.py reads HMAC/DRONE/GITEA secret FILES at import; point them at /dev/null (readable, empty)
|
|
# so the import works in a unit context — parse_trigger doesn't use any of them.
|
|
for _v in ("HMAC_FILE", "DRONE_TOKEN_FILE", "GITEA_TOKEN_FILE"):
|
|
os.environ.setdefault(_v, "/dev/null")
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "bridge"))
|
|
import bridge # noqa: E402
|
|
|
|
|
|
def test_plain_testme_is_cold():
|
|
assert bridge.parse_trigger("!testme") == (True, False)
|
|
assert bridge.parse_trigger(" !testme ") == (True, False) # trimmed
|
|
|
|
|
|
def test_quick_form():
|
|
assert bridge.parse_trigger("!testme --quick") == (True, True)
|
|
assert bridge.parse_trigger(" !testme --quick \n") == (True, True)
|
|
|
|
|
|
def test_non_trigger_forms_rejected():
|
|
for body in (
|
|
"!testmexyz", # the Adversary's classic negative
|
|
"!testme xyz",
|
|
"!testme--quick", # no space → not the quick form
|
|
"!testme --quick", # double space → not an exact match (conservative)
|
|
"please !testme",
|
|
"testme",
|
|
"",
|
|
None,
|
|
):
|
|
assert bridge.parse_trigger(body) == (False, False), body
|