Skip to content

Commit 9f05dbd

Browse files
author
rootware
committed
added new test
1 parent 653e425 commit 9f05dbd

File tree

2 files changed

+69
-4
lines changed

2 files changed

+69
-4
lines changed

tests/test_core_redact.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@ def mocker_text_file(mocker):
6363
def test_redact_all_function_should_return_string_and_dictionary(redactor_obj):
6464
set1 = redactor_obj.redact_all(data)
6565
set2 = ("This is a string", hash_table)
66-
assert type(set1[0]) == type(set2[0]), "1st element of redact_all function should return string"
67-
assert type(set1[1]) == type(set2[1]), "2nd element of redact_all function should return dictionary"
66+
assert type(set1[0]) == str, "1st element of redact_all function should return string"
67+
assert type(set1[1]) == dict, "2nd element of redact_all function should return dictionary"
6868
assert type(set1) == type(set2), "redact_all function should return a tuple"
6969

70-
7170
# def test_process_text_function_should_create_redacted_file_and_json(redactor_obj, tmp_path):
7271
# redactor_obj.process_text(data, tmp_path)
7372
# assert os.path.isfile(tmp_path / "redacted_file.txt"), "redacted_file.txt should be created"
@@ -77,4 +76,4 @@ def test_redact_all_function_should_return_string_and_dictionary(redactor_obj):
7776
# def test_process_core_file_function_should_create_redacted_file_and_json(redactor_obj, mocker_text_file, tmp_path):
7877
# redactor_obj.process_core_file(filename='fakefile', savedir=tmp_path)
7978
# assert os.path.isfile(tmp_path / "redacted_fakefile.txt"), "redacted_fakefile.txt should be created"
80-
# assert os.path.isfile(tmp_path / "redacted_fakefile.json"), "redacted_fakefile.json should be created"
79+
# assert os.path.isfile(tmp_path / "redacted_fakefile.json"), "redacted_fakefile.json should be created"

tests/test_custom_redact_engine.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import pytest
2+
import os
3+
from pyredactkit.custom_redactor import CustomRedactorEngine
4+
data = """John, please get that article on www.linkedin.com to me by 5:00PM on Jan 9th 2012. 4:00 would be ideal, actually. If you have any questions, You can reach me at(519)-236-2723 or get in touch with my associate at [email protected]
5+
this is my IP: 102.23.5.1
6+
My router is : 10.10.10.1
7+
71.159.188.33
8+
81.141.167.45
9+
165.65.59.139
10+
64.248.67.225
11+
12+
https://tech.gov.sg
13+
14+
My email is [email protected]
15+
16+
this is my IP: 102.23.5.1
17+
My router is: 10.10.10.1
18+
71.159.188.33
19+
81.141.167.45
20+
165.65.59.139
21+
64.248.67.225
22+
23+
Card_Number,Card_Family,Credit_Limit,Cust_ID
24+
8638-5407-3631-8196,Premium,530000,CC67088
25+
7106-4239-7093-1515,Gold,18000,CC12076
26+
6492-5655-8241-3530,Premium,596000,CC97173
27+
2868-5606-5152-5706,Gold,27000,CC55858
28+
1438-6906-2509-8219,Platinum,142000,CC90518
29+
2764-7023-8396-5255,Gold,50000,CC49168
30+
4864-7119-5608-7611,Premium,781000,CC66746
31+
5160-8427-6529-3274,Premium,490000,CC28930
32+
6691-5105-1556-4131,Premium,640000,CC76766
33+
1481-2536-2178-7547,Premium,653000,CC18007
34+
1355-1728-8274-9593,Premium,660000,CC23267
35+
9621-6787-7890-7470,Platinum,53000,CC52613
36+
6385-4594-8055-9081,Premium,737000,CC96267
37+
2595-8621-2855-9119,Premium,564000,CC22050
38+
7214-4915-6387-5429,Platinum,172000,CC72302
39+
7908-3850-6633-2606,Gold,43000,CC71044
40+
"""
41+
42+
43+
people_names = "John,Jones,Alex,Bruce"
44+
mask_names = "\u2588" * 15
45+
count_names = 4
46+
hash_table = {}
47+
48+
@pytest.fixture
49+
def custom_redactor():
50+
return CustomRedactorEngine()
51+
52+
53+
@pytest.fixture
54+
def mocker_text_file(mocker):
55+
content = "Message to write on file to be written"
56+
mocked_open = mocker.mock_open(read_data=content)
57+
builtin_open = "builtins.open"
58+
mocker.patch(builtin_open, mocked_open)
59+
60+
61+
# def test_redact_custom_function_should_return_string_and_dictionary(custom_redactor):
62+
# set1 = custom_redactor.redact_custom(data)
63+
# set2 = ("This is a string", hash_table)
64+
# assert isinstance(type(set1[0]), str), "1st element of redact_custom function should return string"
65+
# assert isinstance(type(set1[1]), dict), "2nd element of redact_custom function should return dictionary"
66+
# assert type(set1) == type(set2), "redact_custom function should return a tuple"

0 commit comments

Comments
 (0)