Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions scrubber.py

This file was deleted.

6 changes: 3 additions & 3 deletions tests/fixtures/expected_outputs.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[
{
"name": "email test",
"expected": "Contact me at [REDACTED_EMAIL]"
"expected": "Contact me at [EMAIL_ADDRESS]"
},
{
"name": "phone test",
"expected": "Call me on [REDACTED_PHONE]"
"expected": "Call me on [PHONE_NUMBER]"
},
{
"name": "id test",
"expected": "My ID is [REDACTED_ID]"
"expected": "My ID is [ID_NUMBER]"
},
{
"name": "safe text",
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/pii_inputs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"name": "id test",
"input": "My ID is 12345678"
"input": "My ID is 12345678901"
},
{
"name": "safe text",
Expand Down
11 changes: 9 additions & 2 deletions tests/test_pii_scrubber.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import json
import difflib
from scrubber import scrub_pii
import sys
from pathlib import Path

AI_SERVICE_PATH = Path(__file__).resolve().parents[1] / "app" / "ai-service"
sys.path.insert(0, str(AI_SERVICE_PATH))

from services.pii_scrubber import PIIScrubberService


def load_json(path):
Expand All @@ -10,13 +16,14 @@ def load_json(path):

inputs = load_json("tests/fixtures/pii_inputs.json")
expected = load_json("tests/fixtures/expected_outputs.json")
scrubber = PIIScrubberService()


def test_pii_scrubbing():

for inp, exp in zip(inputs, expected):

result = scrub_pii(inp["input"])
result = scrubber.anonymize(inp["input"])["anonymized_text"]

if result != exp["expected"]:

Expand Down