Skip to content

Commit 83b03a6

Browse files
author
rootware
committed
added tests for runner file
1 parent 1861e53 commit 83b03a6

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

tests/test_runner.py

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,53 @@
11
import pytest
2-
import os
3-
from pyredactkit import runner
2+
from pyredactkit import runner as Runner
43

4+
5+
@pytest.fixture
6+
def mocker_text_file(mocker):
7+
content = "Message to write on file to be written"
8+
mocked_open = mocker.mock_open(read_data=content)
9+
builtin_open = "builtins.open"
10+
mocker.patch(builtin_open, mocked_open)
11+
12+
13+
def test_is_it_file(mocker_text_file, tmp_path):
14+
assert Runner.is_it_file('This is a test string') is False, "is_it_file function should return False for this string"
15+
16+
17+
def test_recursive_file_search(mocker_text_file, tmp_path):
18+
assert Runner.recursive_file_search('This is a test string', 'txt', True) == set(), "recursive_file_search function should return an empty set"
19+
20+
21+
def test_api_identify_sensitive_data(mocker_text_file, tmp_path):
22+
test_string = """this is my IP: 102.23.5.1
23+
My router is : 10.10.10.1
24+
71.159.188.33
25+
81.141.167.45
26+
165.65.59.139
27+
64.248.67.225
28+
https://tech.gov.sg
29+
My email is [email protected]
30+
this is my IP: 102.23.5.1
31+
My router is: 10.10.10.1
32+
71.159.188.33
33+
81.141.167.45
34+
165.65.59.139
35+
64.248.67.225
36+
Base64 data
37+
QVBJX1RPS0VO
38+
UzNjcjN0UGFzc3dvcmQ=
39+
U3VwM3JTM2NyZXRQQHNzd29yZA==
40+
Singapore NRIC
41+
G0022121F
42+
F2121200F
43+
G1021022E
44+
S1022221L
45+
G1222221C
46+
S0000212Q
47+
F2120212E
48+
S0021001P
49+
"""
50+
test_data = ['102.23.5.1', '10.10.10.1', '71.159.188.33', '81.141.167.45', '165.65.59.139', '64.248.67.225', 'https://tech.gov.sg', '[email protected]', 'mail.com', '102.23.5.1', '10.10.10.1', '71.159.188.33', '81.141.167.45', '165.65.59.139', '64.248.67.225', 'QVBJX1RPS0VO', 'UzNjcjN0UGFzc3dvcmQ=', 'U3VwM3JTM2NyZXRQQHNzd29yZA==', 'G0022121F', 'F2121200F', 'G1021022E', 'S1022221L', 'G1222221C', 'S0000212Q', 'F2120212E', 'S0021001P']
51+
52+
assert Runner.api_identify_sensitive_data(test_string) == test_data, "api_identify_sensitive_data function should return an empty set"
53+
assert Runner.api_identify_sensitive_data('This is a test string') == [], "api_identify_sensitive_data function should return an empty list"

0 commit comments

Comments
 (0)