-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathtest_team_t2.py
109 lines (82 loc) · 4.8 KB
/
test_team_t2.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import unittest
from pii_team_t2 import *
class TeamFrostTests(unittest.TestCase):
def test_find_us_phone_number(self):
results_list = find_us_phone_number('My phone number is 123-456-7890')
self.assertEqual(results_list, ['123-456-7890']) # add assertion here
def test_find_visa_mastercard(self):
results_list = find_visa_mastercard('My credit card number is 1234-5678-9012-3456')
self.assertEqual(results_list[0], "1234-5678-9012-3456")
results_list = find_visa_mastercard('1234-5678-9012-3456 is my credit card number')
self.assertEqual(results_list[0], "1234-5678-9012-3456")
results_list = find_visa_mastercard('The number, 1234-5678-9012-3456, could be my credit card number')
self.assertEqual(results_list[0], "1234-5678-9012-3456")
results_list = find_visa_mastercard('The number, 1234-5678-9012-3456, is my credit card number, '
'but 3245-7397-9275-2643, and 9432-7849-7234-2987 are my old numbers.')
self.assertEqual(results_list[0], "1234-5678-9012-3456")
self.assertEqual(results_list[1], "3245-7397-9275-2643")
self.assertEqual(results_list[2], "9432-7849-7234-2987")
def test_find_amex(self):
results_list = find_amex('My Amex card number is 1234-567890-12345')
self.assertEqual(results_list[0], "1234-567890-12345")
results_list = find_amex('1234-567890-12345 is my Amex card number')
self.assertEqual(results_list[0], "1234-567890-12345")
results_list = find_amex('The number, 1234-567890-12345, could be my Amex card number')
self.assertEqual(results_list[0], "1234-567890-12345")
results_list = find_amex('The number 1234-567890-12345 is my Amex card number,'
' but 8765-295653-01928 and 7205-592436-07632 are my old numbers')
self.assertEqual(results_list[0], "1234-567890-12345")
self.assertEqual(results_list[1], "8765-295653-01928")
self.assertEqual(results_list[2], "7205-592436-07632")
def test_find_us_ssn(self):
# Test a single SSN with dashes
results_list = find_us_ssn('My social security number is 123-45-6789')
self.assertEqual(results_list[0], '123-45-6789')
# Test a single SSN without dashes
results_list = find_us_ssn('My social security number is 123456789')
self.assertEqual(results_list[0], '123456789')
# Test SSN at start of string
results_list = find_us_ssn('123456789 is my social security number.')
self.assertEqual(results_list[0], '123456789')
# Test SSN in middle of string
results_list = find_us_ssn('My SSN 123456789 has been compromised.')
self.assertEqual(results_list[0], '123456789')
# Test SSN with dashes at end of string
results_list = find_us_ssn('My SSN is 123-45-6789.')
self.assertEqual(results_list[0], '123-45-6789')
# Test multiple SSN within string
results_list = find_us_ssn('My SSN is 123456789 and his is 987-65-4321.')
self.assertEqual(results_list[0], '123456789')
self.assertEqual(results_list[1], '987-65-4321')
def test_find_email(self):
results_list = find_email('My email address is jim.jones@jones.com')
self.assertEqual(results_list[0], 'jim.jones@jones.com')
#testing alphabetical
def test_find_instagram_handle(self):
results_list = find_instagram_handle('My instagram handle is @ariorwateva')
self.assertEqual(results_list[0], '@ariorwateva')
#testing non case-sensitive
def test_find_instagram_handle(self):
results_list = find_instagram_handle('My instagram handle is @Ariorwateva')
self.assertEqual(results_list[0], '@Ariorwateva')
#testing non alphanumeric
def test_find_instagram_handle(self):
results_list = find_instagram_handle('My instagram handle is @ariorwateva25')
self.assertEqual(results_list[0], '@ariorwateva25')
#testing underscore
def test_find_instagram_handle(self):
results_list = find_instagram_handle('My instagram handle is @ariorwateva_')
self.assertEqual(results_list[0], '@ariorwateva_')
#testing '.'
def test_find_instagram_handle(self):
results_list = find_instagram_handle('My instagram handle is @ari.orwateva')
self.assertEqual(results_list[0], '@ari.orwateva')
#testing invalid case with no @
def test_find_instagram_handle(self):
results_list = find_instagram_handle('My instagram handle is ariorwateva')
self.assertFalse(results_list)
def test_find_instagram_handle(self):
results_list = find_instagram_handle('@ariorwateva is my IG')
self.assertEqual(results_list[0], '@ariorwateva')
if __name__ == '__main__':
unittest.main()