-
Notifications
You must be signed in to change notification settings - Fork 0
Test pii scan #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
claesmk
wants to merge
17
commits into
main
Choose a base branch
from
test_pii_scan
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Test pii scan #34
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
bf6092f
Add CRYPTO test case
milesmjohnson c445b26
Make sure test fails if CRYPTO not detected
claesmk daaa326
Additional safety checks
claesmk 1d4484a
Added more 2.2.359 changes
claesmk e59d470
Merge branch 'main' into test_pii_scan
claesmk 2a479f5
Update test_pii_scan.py
claesmk afd9661
Update test_pii_scan.py
claesmk e58afc9
Update test_pii_scan.py
claesmk 020ee4b
Removed CRYPTO because not merged yet
claesmk 1f407dc
Update test_pii_scan.py
claesmk 846263d
Update test_pii_scan.py
claesmk dc1a705
Update test_pii_scan.py
claesmk f1d8226
Update test_pii_scan.py
claesmk 49d5d85
Fixed copilot missed import
claesmk b7c2122
Update test_pii_scan.py
claesmk 340ed6f
Update test_pii_scan.py
claesmk eb8d75c
Fixed pylint warnings after copilot changes
claesmk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| """Some unit tests for the PII scan module.""" | ||
| import unittest | ||
| import os | ||
| import ast | ||
| from pii_scan import show_aggie_pride, analyze_text | ||
|
|
||
|
|
||
| class TestPIIScan(unittest.TestCase): | ||
| """Test cases for PII scan module.""" | ||
| def test_aggie_pride(self): | ||
| """Test to make sure the Aggie Pride function works""" | ||
| self.assertEqual('Aggie Pride - Worldwide', show_aggie_pride()) | ||
|
|
||
| def test_base_supported_entities(self): | ||
| """Test to make sure the default expected supported entities are returned""" | ||
| results = analyze_text('', [], show_supported=True) | ||
| supported_entities = ['IP_ADDRESS', | ||
| 'MEDICAL_LICENSE', | ||
| 'LOCATION', | ||
| 'EMAIL_ADDRESS', | ||
| 'DATE_TIME', | ||
| 'ORGANIZATION', | ||
| 'CREDIT_CARD', | ||
| 'CRYPTO', | ||
| 'AU_MEDICARE', | ||
| 'AU_ABN', | ||
| 'PHONE_NUMBER', | ||
| 'US_PASSPORT', | ||
| 'IBAN_CODE', | ||
| 'AU_TFN', | ||
| 'US_BANK_NUMBER', | ||
| 'NRP', | ||
| 'UK_NHS', | ||
| 'UK_NINO', | ||
| 'US_SSN', | ||
| 'PERSON', | ||
| 'URL', | ||
| 'US_ITIN', | ||
| 'US_DRIVER_LICENSE', | ||
| 'AU_ACN', | ||
| 'IT_VAT_CODE', | ||
| 'IT_IDENTITY_CARD', | ||
| 'IT_DRIVER_LICENSE', | ||
| 'IT_PASSPORT', | ||
| 'IT_FISCAL_CODE', | ||
| 'FI_PERSONAL_IDENTITY_CODE', | ||
| 'PL_PESEL', | ||
| 'ES_NIE', | ||
| 'ES_NIF', | ||
| 'ABA_ROUTING_NUMBER', | ||
| 'IN_VEHICLE_REGISTRATION', | ||
| 'IN_PASSPORT', | ||
| 'IN_VOTER', | ||
| 'IN_AADHAAR', | ||
| 'IN_PAN'] | ||
|
claesmk marked this conversation as resolved.
Outdated
|
||
|
|
||
| for entity in supported_entities: | ||
| self.assertIn(entity, results) | ||
|
|
||
| def test_starts_with_test(self): | ||
| """Test to make sure all test methods start with test""" | ||
| # In order to run as a test case the method name must start with test | ||
| # This test checks to make sure all defines within test files start with test | ||
| # This is a common mistake that can cause tests to be skipped | ||
| from pathlib import Path | ||
| for file in Path(os.path.dirname(__file__)).glob('test_*.py'): | ||
| with file.open(encoding='utf-8') as f: | ||
| tree = ast.parse(f.read(), filename=file) | ||
| for node in ast.walk(tree): | ||
|
claesmk marked this conversation as resolved.
Outdated
|
||
| if isinstance(node, ast.FunctionDef): | ||
| method_name = node.name | ||
| # Skip legitimate non-test methods like setUp, tearDown, and private methods | ||
| if method_name in {'setUp', 'tearDown'} or method_name.startswith('_'): | ||
| continue | ||
| self.assertTrue(method_name.startswith('test'), | ||
| f'Method name does not start with test: def {method_name} in {file}') | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.