ec397f2c65
v0.5 (Live Assist — on-the-job voice companion) milestone complete. 4 phases: P0 (pre-execution, v0.1.10) → P1 (assist core + guardrail, v0.1.11) → P2 (integration + tech-debt + NFR, v0.1.12) → P3 (final review + ship, v0.1.13 = milestone release). 16/16 REQs covered (3 ASSIST + 4 NFR + 9 IDEATE). 4 v0.6 backlog. 469 tests passed, 0 failed. 1 P0 fixed (guardrail processor safety). 8 P1+ flagged for v0.6. 8 v0.4 P1+ tech-debt addressed. G-049 + G-067 grill MUSTs resolved. ESCALATION-01 (PIPEDA) OPEN for human legal review before assist surface go-live. ---ci--- project: praxis phase: 3 milestone: v0.5 status: complete requirements: covered: [REQ-ASSIST-01, REQ-ASSIST-02, REQ-ASSIST-03, REQ-NFR-ASSIST-01, REQ-NFR-ASSIST-02, REQ-NFR-ASSIST-03, REQ-NFR-ASSIST-04, REQ-IDEATE-01, REQ-IDEATE-02, REQ-IDEATE-03, REQ-IDEATE-04, REQ-IDEATE-05, REQ-IDEATE-06, REQ-IDEATE-07, REQ-IDEATE-08, REQ-IDEATE-09] partial: [] ---/ci---
61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
"""Unit tests for the customer-speech PII policy (TASK-04-04, REQ-IDEATE-05)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from server.assist.pii_policy import (
|
|
CUSTOMER_SPEECH_POLICY,
|
|
RETENTION_DAYS,
|
|
get_pii_policy,
|
|
redact_pii,
|
|
)
|
|
|
|
|
|
def test_redact_phone_number():
|
|
assert redact_pii("Call me at 416-555-1234") == "Call me at [PHONE]"
|
|
assert redact_pii("Call me at 416.555.1234") == "Call me at [PHONE]"
|
|
assert redact_pii("Call me at 4165551234") == "Call me at [PHONE]"
|
|
|
|
|
|
def test_redact_email():
|
|
assert redact_pii("Email me at john@example.com") == "Email me at [EMAIL]"
|
|
assert redact_pii("Send to john.doe+test@sub.example.co.uk") == "Send to [EMAIL]"
|
|
|
|
|
|
def test_redact_card_number():
|
|
assert redact_pii("My card is 4111-1111-1111-1111") == "My card is [CARD]"
|
|
assert redact_pii("My card is 4111 1111 1111 1111") == "My card is [CARD]"
|
|
|
|
|
|
def test_redact_sin_like_number():
|
|
assert redact_pii("My SIN is 123-456-789") == "My SIN is [SIN]"
|
|
|
|
|
|
def test_no_false_redactions():
|
|
"""Numbers that aren't PII patterns are not redacted."""
|
|
assert redact_pii("I have 3 kids") == "I have 3 kids"
|
|
assert redact_pii("Order #12345") == "Order #12345"
|
|
assert redact_pii("That's 25% off") == "That's 25% off"
|
|
|
|
|
|
def test_redact_empty_string():
|
|
assert redact_pii("") == ""
|
|
|
|
|
|
def test_redact_multiple_patterns():
|
|
text = "Call 416-555-1234 or email john@example.com, card 4111-1111-1111-1111"
|
|
redacted = redact_pii(text)
|
|
assert "[PHONE]" in redacted
|
|
assert "[EMAIL]" in redacted
|
|
assert "[CARD]" in redacted
|
|
|
|
|
|
def test_get_pii_policy_returns_dict():
|
|
policy = get_pii_policy()
|
|
assert policy["policy"] == CUSTOMER_SPEECH_POLICY
|
|
assert policy["retention_days"] == RETENTION_DAYS
|
|
assert RETENTION_DAYS == 30
|
|
assert "phone" in policy["redaction_patterns"]
|
|
assert "email" in policy["redaction_patterns"]
|
|
assert "card" in policy["redaction_patterns"]
|
|
assert "sin-like" in policy["redaction_patterns"]
|
|
assert "pending" in policy["legal_review"].lower() |