Ejemplo n.º 1
0
 def test_no_ccns(self):
     """
     Shouldn't be any raw CCNs in num_safe(text). 'text' 
     is imported from ccn_safety.py.
     """
     pattern = r"(\d{4}(-| )\d{4}(-| )\d{4}(-| )\d{4})"
     self.assertIsNone(re.search(pattern, num_safe(text)))
Ejemplo n.º 2
0
 def test_no_ccns(self):
     """
     Shouldn't be any raw CCNs in num_safe(text). 'text' 
     is imported from ccn_safety.py.
     """
     pattern = r"(\d{4}(-| )\d{4}(-| )\d{4}(-| )\d{4})"
     self.assertIsNone(re.search(pattern, num_safe(text)))
Ejemplo n.º 3
0
 def test_iter(self):
     """
     Need some practice with re.finditer()
     """
     pattern = r"((X{4}-){3}\d{4})"
     m = re.finditer(pattern, num_safe(newtext))
     expected = [
         'XXXX-XXXX-XXXX-3456', 'XXXX-XXXX-XXXX-8765', 'XXXX-XXXX-XXXX-5791'
     ]
     self.assertEqual([a.group() for a in m], expected)
Ejemplo n.º 4
0
 def test_iter(self):
     """
     Need some practice with re.finditer()
     """
     pattern = r"((X{4}-){3}\d{4})"
     m = re.finditer(pattern, num_safe(newtext))
     expected = [ 'XXXX-XXXX-XXXX-3456', 
             'XXXX-XXXX-XXXX-8765', 
             'XXXX-XXXX-XXXX-5791']
     self.assertEqual([ a.group() for a in m ], expected)
Ejemplo n.º 5
0
 def test_re_mojo(self):
     """
     Test that 'findall(pattern, num_safe(newtext))' gets returned with
     properly fixed CCNs"
     """
     pattern = r"(X{4}-X{4}-X{4}-\d{4})"
     test = re.findall(pattern, num_safe(newtext))
     self.assertEqual(test[0], 'XXXX-XXXX-XXXX-3456')
     self.assertEqual(test[1], 'XXXX-XXXX-XXXX-8765')
     self.assertEqual(test[2], 'XXXX-XXXX-XXXX-5791')
     self.assertEqual(len(test), 3)
Ejemplo n.º 6
0
 def test_re_mojo(self):
     """
     Test that 'findall(pattern, num_safe(newtext))' gets returned with
     properly fixed CCNs"
     """
     pattern = r"(X{4}-X{4}-X{4}-\d{4})"
     test = re.findall(pattern, num_safe(newtext))
     self.assertEqual(test[0], 'XXXX-XXXX-XXXX-3456')
     self.assertEqual(test[1], 'XXXX-XXXX-XXXX-8765')
     self.assertEqual(test[2], 'XXXX-XXXX-XXXX-5791')
     self.assertEqual(len(test), 3)
Ejemplo n.º 7
0
 def test_txt(self):
     "Entire passages with ccn's should be correct."
     self.assertEqual(num_safe(txt2test), fixed_txt)
Ejemplo n.º 8
0
 def test_sub(self):
     "Tests that simple substitutions are okay"
     self.assertEqual(num_safe("1234-1234-1234-1234"),
                      "XXXX-XXXX-XXXX-1234")
     self.assertEqual(num_safe("1234 1234 1234 1234"),
                      "XXXX-XXXX-XXXX-1234")
Ejemplo n.º 9
0
 def test_txt(self):
     "Entire passages with ccn's should be correct."
     self.assertEqual(num_safe(txt2test), fixed_txt)
Ejemplo n.º 10
0
 def test_sub(self):
     "Tests that simple substitutions are okay"
     self.assertEqual(num_safe("1234-1234-1234-1234"), "XXXX-XXXX-XXXX-1234")
     self.assertEqual(num_safe("1234 1234 1234 1234"), "XXXX-XXXX-XXXX-1234")