-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EM version without middleware interaction
- Loading branch information
Showing
2 changed files
with
27 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,8 +33,7 @@ def test_mask(): | |
|
||
# Act | ||
test_text = "Mr. George Collins lives at 123 Main St, Anytown, USA 12345.\n His phone number is 555-1234.\nJane Smith resides at 456 Elm Avenue, Othercity, State 67890, and can be reached at (987) 654-3210.\nThe company's CEO, Robert Johnson, has an office at 789 Corporate Blvd, Suite 500, Bigcity, State 13579. \nFor customer service, call 1-800-555-9876 or email [email protected]. \nSarah Lee, our HR manager, can be contacted at 444-333-2222 or [email protected].\nThe project budget is $250,000, with an additional $50,000 allocated for contingencies. \nMonthly maintenance costs are estimated at $3,500. \nFor international clients, please use +1-555-987-6543. \nOur tax ID number is 12-3456789." | ||
|
||
# Act | ||
|
||
result = asyncio.run(process.mask_content(test_text)) | ||
|
||
# Assert | ||
|
@@ -84,8 +83,18 @@ def test_mask(): | |
# Test unmasking | ||
unmasked_content = process.unmask_content(result.masked_text, result.mapping) | ||
|
||
# Optionally, verify the entire unmasked content matches the original | ||
assert unmasked_content == test_text, "Unmasked content does not match the original content" | ||
# Normalize strings by standardizing whitespace and newlines | ||
def normalize_string(s: str) -> str: | ||
# Replace all whitespace sequences (including newlines) with a single space | ||
# and strip leading/trailing whitespace | ||
return ' '.join(s.split()) | ||
|
||
# Test unmasking with normalized strings | ||
normalized_unmasked = normalize_string(unmasked_content) | ||
normalized_original = normalize_string(test_text) | ||
|
||
# Compare normalized strings | ||
assert normalized_unmasked == normalized_original, "Unmasked content does not match the original content" | ||
|
||
def test_simple_use_case(): | ||
# Arrange | ||
|
@@ -133,6 +142,19 @@ def test_deterministic_hashing(): | |
|
||
test_text = "John Doe transferred $5000 to Jane Smith on 2021-05-01." | ||
|
||
# Normalize strings by standardizing whitespace and newlines | ||
def normalize_string(s: str) -> str: | ||
# Replace all whitespace sequences (including newlines) with a single space | ||
# and strip leading/trailing whitespace | ||
return ' '.join(s.split()) | ||
|
||
# Test unmasking with normalized strings | ||
normalized_unmasked = normalize_string(result.masked_text) | ||
normalized_original = normalize_string(test_text) | ||
|
||
# Compare normalized strings | ||
assert normalized_unmasked == normalized_original, "Unmasked content does not match the original content" | ||
|
||
# Act | ||
result = asyncio.run(process.mask_content(test_text)) | ||
|
||
|