|  | 
| 1 |  | -# import os | 
| 2 |  | -# import sys | 
|  | 1 | +import os | 
|  | 2 | +import sys | 
| 3 | 3 | 
 | 
| 4 |  | -# import requests | 
|  | 4 | +import requests | 
| 5 | 5 | 
 | 
| 6 |  | -# from datafog import PresidioEngine as presidio | 
|  | 6 | +from datafog import PresidioEngine as presidio | 
| 7 | 7 | 
 | 
| 8 |  | -# sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) | 
|  | 8 | +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) | 
| 9 | 9 | 
 | 
| 10 | 10 | 
 | 
| 11 |  | -# def test_piiscan_json_detection(): | 
| 12 |  | -#     # Assuming sample_file already contains the data you want to test | 
| 13 |  | -#     sample_file = "tests/files/input_files/sample.json" | 
|  | 11 | +def test_piiscan_json_detection(): | 
|  | 12 | +    # Assuming sample_file already contains the data you want to test | 
|  | 13 | +    sample_file = "tests/files/input_files/sample.json" | 
| 14 | 14 | 
 | 
| 15 |  | -#     # Read the contents of sample_file into original_value | 
| 16 |  | -#     with open(sample_file, "r") as f: | 
| 17 |  | -#         original_value = f.read() | 
|  | 15 | +    # Read the contents of sample_file into original_value | 
|  | 16 | +    with open(sample_file, "r") as f: | 
|  | 17 | +        original_value = f.read() | 
| 18 | 18 | 
 | 
| 19 |  | -#     pii_detected = presidio.scan(original_value) | 
|  | 19 | +    pii_detected = presidio.scan(original_value) | 
| 20 | 20 | 
 | 
| 21 |  | -#     # write pii_detected to a JSON file called output.json in the same directory as sample_file | 
| 22 |  | -#     with open( | 
| 23 |  | -#         "tests/files/output_files/output.json", | 
| 24 |  | -#         "w", | 
| 25 |  | -#     ) as f: | 
| 26 |  | -#         for entity in pii_detected: | 
| 27 |  | -#             f.write(entity.entity_type) | 
| 28 |  | -#             f.write("\n") | 
|  | 21 | +    # write pii_detected to a JSON file called output.json in the same directory as sample_file | 
|  | 22 | +    with open( | 
|  | 23 | +        "tests/files/output_files/output.json", | 
|  | 24 | +        "w", | 
|  | 25 | +    ) as f: | 
|  | 26 | +        for entity in pii_detected: | 
|  | 27 | +            f.write(entity.entity_type) | 
|  | 28 | +            f.write("\n") | 
| 29 | 29 | 
 | 
| 30 | 30 | 
 | 
| 31 |  | -# def test_piiscan_csv_detection(): | 
| 32 |  | -#     # Assuming sample_file already contains the data you want to test | 
| 33 |  | -#     sample_file = "tests/files/input_files/sample.csv" | 
|  | 31 | +def test_piiscan_csv_detection(): | 
|  | 32 | +    # Assuming sample_file already contains the data you want to test | 
|  | 33 | +    sample_file = "tests/files/input_files/sample.csv" | 
| 34 | 34 | 
 | 
| 35 |  | -#     # Read the contents of sample_file into original_value | 
| 36 |  | -#     with open(sample_file, "r") as f: | 
| 37 |  | -#         original_value = f.read() | 
|  | 35 | +    # Read the contents of sample_file into original_value | 
|  | 36 | +    with open(sample_file, "r") as f: | 
|  | 37 | +        original_value = f.read() | 
| 38 | 38 | 
 | 
| 39 |  | -#     pii_detected = presidio.scan(original_value) | 
|  | 39 | +    pii_detected = presidio.scan(original_value) | 
| 40 | 40 | 
 | 
| 41 |  | -#     # write pii_detected to a JSON file called output.json in the same directory as sample_file | 
| 42 |  | -#     with open( | 
| 43 |  | -#         "tests/files/output_files/output.csv", | 
| 44 |  | -#         "w", | 
| 45 |  | -#     ) as f: | 
| 46 |  | -#         for entity in pii_detected: | 
| 47 |  | -#             f.write(entity.entity_type) | 
| 48 |  | -#             f.write("\n") | 
|  | 41 | +    # write pii_detected to a JSON file called output.json in the same directory as sample_file | 
|  | 42 | +    with open( | 
|  | 43 | +        "tests/files/output_files/output.csv", | 
|  | 44 | +        "w", | 
|  | 45 | +    ) as f: | 
|  | 46 | +        for entity in pii_detected: | 
|  | 47 | +            f.write(entity.entity_type) | 
|  | 48 | +            f.write("\n") | 
| 49 | 49 | 
 | 
| 50 | 50 | 
 | 
| 51 |  | -# def test_piiscan_txt_detection(): | 
| 52 |  | -#     # Assuming sample_file already contains the data you want to test | 
| 53 |  | -#     sample_file = "tests/files/input_files/sample.txt" | 
| 54 |  | -#     # Read the contents of sample_file into original_value | 
| 55 |  | -#     with open(sample_file, "r") as f: | 
| 56 |  | -#         original_value = f.read() | 
|  | 51 | +def test_piiscan_txt_detection(): | 
|  | 52 | +    # Assuming sample_file already contains the data you want to test | 
|  | 53 | +    sample_file = "tests/files/input_files/sample.txt" | 
|  | 54 | +    # Read the contents of sample_file into original_value | 
|  | 55 | +    with open(sample_file, "r") as f: | 
|  | 56 | +        original_value = f.read() | 
| 57 | 57 | 
 | 
| 58 |  | -#     pii_detected = presidio.scan(original_value) | 
|  | 58 | +    pii_detected = presidio.scan(original_value) | 
| 59 | 59 | 
 | 
| 60 |  | -#     # write pii_detected to a JSON file called output.json in the same directory as sample_file | 
| 61 |  | -#     with open( | 
| 62 |  | -#         "tests/files/output_files/output.txt", | 
| 63 |  | -#         "w", | 
| 64 |  | -#     ) as f: | 
| 65 |  | -#         for entity in pii_detected: | 
| 66 |  | -#             f.write(entity.entity_type) | 
| 67 |  | -#             f.write("\n") | 
|  | 60 | +    # write pii_detected to a JSON file called output.json in the same directory as sample_file | 
|  | 61 | +    with open( | 
|  | 62 | +        "tests/files/output_files/output.txt", | 
|  | 63 | +        "w", | 
|  | 64 | +    ) as f: | 
|  | 65 | +        for entity in pii_detected: | 
|  | 66 | +            f.write(entity.entity_type) | 
|  | 67 | +            f.write("\n") | 
| 68 | 68 | 
 | 
| 69 | 69 | 
 | 
| 70 |  | -# def test_piiscan_url_detection(): | 
| 71 |  | -#     # Assuming sample_file already contains the data you want to test | 
| 72 |  | -#     sample_url = "https://gist.githubusercontent.com/sidmohan0/1aa3ec38b4e6594d3c34b113f2e0962d/raw/42e57146197be0f85a5901cd1dcdd9ad15b31bab/sotu_2023.txt" | 
|  | 70 | +def test_piiscan_url_detection(): | 
|  | 71 | +    # Assuming sample_file already contains the data you want to test | 
|  | 72 | +    sample_url = "https://gist.githubusercontent.com/sidmohan0/1aa3ec38b4e6594d3c34b113f2e0962d/raw/42e57146197be0f85a5901cd1dcdd9ad15b31bab/sotu_2023.txt" | 
| 73 | 73 | 
 | 
| 74 |  | -#     response = requests.get(sample_url) | 
| 75 |  | -#     original_value = response.text | 
| 76 |  | -#     pii_detected = presidio.scan(original_value) | 
|  | 74 | +    response = requests.get(sample_url) | 
|  | 75 | +    original_value = response.text | 
|  | 76 | +    pii_detected = presidio.scan(original_value) | 
| 77 | 77 | 
 | 
| 78 |  | -#     # write pii_detected to a output.md in the same directory as sample_url | 
| 79 |  | -#     with open( | 
| 80 |  | -#         "tests/files/output_files/output.md", | 
| 81 |  | -#         "w", | 
| 82 |  | -#     ) as f: | 
| 83 |  | -#         for entity in pii_detected: | 
| 84 |  | -#             f.write(entity.entity_type) | 
| 85 |  | -#             f.write("\n") | 
|  | 78 | +    # write pii_detected to a output.md in the same directory as sample_url | 
|  | 79 | +    with open( | 
|  | 80 | +        "tests/files/output_files/output.md", | 
|  | 81 | +        "w", | 
|  | 82 | +    ) as f: | 
|  | 83 | +        for entity in pii_detected: | 
|  | 84 | +            f.write(entity.entity_type) | 
|  | 85 | +            f.write("\n") | 
0 commit comments