-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix failing pre-commit hook fails on directories (#17)
* Add test for get flagged lines * Skip PII flag check for directories
- Loading branch information
1 parent
3c439aa
commit 3db5d4a
Showing
8 changed files
with
31 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pytest==7.2.1 | ||
pytest-check==2.1.2 | ||
python-dotenv==0.19.0 | ||
requests==2.28.1 |
Empty file.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Credit card number: 1234 5678 9101 1123 |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
PII_CHECK:OFF | ||
Some content in between the flags. Ideally this content won't be checked for PII. | ||
Below is a dummy PII to check this | ||
Credit card number: 1234 5678 9101 1123 | ||
CVV: 123 | ||
PII_CHECK:ON | ||
|
||
Some content where the check will be performed. | ||
Credit card number: 1234 5678 9101 1123 | ||
CVV: 123 |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Here's some content. |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
./dir_with_files |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pytest_check as check | ||
from pii_check.pii_check_hook import get_flagged_lines | ||
|
||
|
||
def test_get_flagged_lines(): | ||
files = [ | ||
"tests/test_data/dir_with_files/file_with_pii.txt", "tests/test_data/dir_with_files/file_without_pii.txt", | ||
"tests/test_data/dir_with_files/file_with_pii_flag_on", "tests/test_data/dir_with_files/file_with_pii_flag_off", | ||
"tests/test_data/dir_with_files/file_with_pii_flag", "tests/test_data/symlink_of_dir_with_files" | ||
] | ||
res = get_flagged_lines(files) | ||
check.equal(res, [(1, 6, 'tests/test_data/dir_with_files/file_with_pii_flag')]) | ||
|