-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_team_technigals.py
More file actions
77 lines (60 loc) · 2.49 KB
/
test_team_technigals.py
File metadata and controls
77 lines (60 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import unittest
from pii_scan import analyze_text
class TestTeamTechniGALS(unittest.TestCase):
def test_gender_detect(self):
"""Test to make sure gender is detected"""
# positive test cases
results = analyze_text('my gender is female')
print(results)
self.assertIn('GENDER', str(results))
results = analyze_text('my gender is male')
print(results)
self.assertIn('GENDER', str(results))
results = analyze_text('my gender is non-binary')
print(results)
self.assertIn('GENDER', str(results))
# negative test case
results = analyze_text('my gender is november')
print(results)
self.assertNotIn('GENDER', str(results))
def test_bank_account_number(self):
"""Test to find bank account number"""
results = analyze_text('my bank account number is: 1234567890')
print(results)
self.assertIn('US_BANK_NUMBER', str(results))
results = analyze_text('my bank account number is: ABC123')
print(results)
self.assertNotIn('US_BANK_NUMBER', str(results))
def test_int_num_detect(self):
results = analyze_text('123-123-1234-1234')
print(results)
self.assertIn('INTERNATIONAL_PN', str(results))
results = analyze_text('123-123-1234-123')
print(results)
self.assertNotIn('INTERNATIONAL_PN', str(results))
results = analyze_text('1231231234123')
print(results)
self.assertNotIn('INTERNATIONAL_PN', str(results))
def test_detect_usernames(self):
# Test a valid username
valid_result = analyze_text('@comp410Rocks')
self.assertIn("USERNAME", str(valid_result), "Valid username not detected")
# Test an invalid organization
invalid_result = analyze_text('John Smith')
self.assertNotIn("USERNAME", str(invalid_result), "Invalid organization incorrectly detected")
def test_zipcode(self):
"""Test to find zipcode of user"""
# positive testcases
results = analyze_text('27401')
print(results)
self.assertIn('ZIPCODE', str(results))
results = analyze_text('30135-0000')
print(results)
self.assertIn('ZIPCODE', str(results))
# negative testcases
results = analyze_text('1234567890')
print(results)
self.assertNotIn('ZIPCODE', str(results))
results = analyze_text('1234')
print(results)
self.assertNotIn('ZIPCODE', str(results))