Beispiel #1
0
 def test_search_string_non_luhn(self):
     ps = PanScanner()
     n = '4111111111111113'
     test_match = ps.reqex.match(n)
     self.assertTrue(test_match)
     matches = ps.search_string(n)
     self.assertEqual(len(matches), 0)
Beispiel #2
0
 def test_search_string_non_luhn(self):
     ps = PanScanner()
     n = '4111111111111113'
     test_match = ps.reqex.match(n)
     self.assertTrue(test_match)
     matches = ps.search_string(n)
     self.assertEqual(len(matches), 0)
Beispiel #3
0
 def test_search_string_two_match(self):
     ps = PanScanner()
     matches = ps.search_string('there is one match: 4111111111111111'
                                'no two matches (!): 4111111111111111')
     self.assertEqual(len(matches), 2)
     self.assertEqual(matches[0].span(), (20, 36))
     self.assertEqual(matches[1].span(), (56, 72))
     self.assertEqual(matches[0].group(0), '4111111111111111')
     self.assertEqual(matches[1].group(0), '4111111111111111')
Beispiel #4
0
 def test_search_string_two_match(self):
     ps = PanScanner()
     matches = ps.search_string('there is one match: 4111111111111111'
                                'no two matches (!): 4111111111111111')
     self.assertEqual(len(matches), 2)
     self.assertEqual(matches[0].span(), (20, 36))
     self.assertEqual(matches[1].span(), (56, 72))
     self.assertEqual(matches[0].group(0), '4111111111111111')
     self.assertEqual(matches[1].group(0), '4111111111111111')
Beispiel #5
0
    def test_search_file_binary(self):
        searched_lines = []
        ps = PanScanner()
        ps.search_string = lambda l: searched_lines.append(l)

        filename = get_absolute_path('test_dir/binary.png')
        ps.search_file(filename)
        self.assertEqual(searched_lines, [])
        self.assertEqual(len(ps.failed_to_open), 0)
Beispiel #6
0
    def test_search_file_binary(self):
        searched_lines = []
        ps = PanScanner()
        ps.search_string = lambda l: searched_lines.append(l)

        filename = get_absolute_path('test_dir/binary.png')
        ps.search_file(filename)
        self.assertEqual(searched_lines, [])
        self.assertEqual(len(ps.failed_to_open), 0)
Beispiel #7
0
 def test_search_string_letter_surrounded(self):
     ps = PanScanner()
     matches = ps.search_string('asd4111111111111111asd')
     self.assertEqual(len(matches), 1)
     self.assertEqual(matches[0].group(0), '4111111111111111')
Beispiel #8
0
 def test_search_string_comma_surrounded(self):
     ps = PanScanner()
     matches = ps.search_string(',4111111111111111')
     self.assertEqual(len(matches), 0)
     matches = ps.search_string('4111111111111111,')
     self.assertEqual(len(matches), 0)
Beispiel #9
0
 def test_search_string_number_surrounded(self):
     ps = PanScanner()
     matches = ps.search_string('3334111111111111111333')
     self.assertEqual(len(matches), 0)
Beispiel #10
0
 def test_search_string_no_matches(self):
     ps = PanScanner()
     matches = ps.search_string('there is no match :(')
     self.assertEqual(len(matches), 0)
Beispiel #11
0
 def test_search_string_ignore_test_card_numbers(self):
     ps = PanScanner(ignore_test_card_numbers=True)
     matches = ps.search_string('4111111111111111')
     self.assertEqual(len(matches), 0)
     matches = ps.search_string('4716334938933348')
     self.assertEqual(len(matches), 1)
Beispiel #12
0
 def test_search_string_letter_surrounded(self):
     ps = PanScanner()
     matches = ps.search_string('asd4111111111111111asd')
     self.assertEqual(len(matches), 1)
     self.assertEqual(matches[0].group(0), '4111111111111111')
Beispiel #13
0
 def test_search_string_comma_surrounded(self):
     ps = PanScanner()
     matches = ps.search_string(',4111111111111111')
     self.assertEqual(len(matches), 0)
     matches = ps.search_string('4111111111111111,')
     self.assertEqual(len(matches), 0)
Beispiel #14
0
 def test_search_string_number_surrounded(self):
     ps = PanScanner()
     matches = ps.search_string('3334111111111111111333')
     self.assertEqual(len(matches), 0)
Beispiel #15
0
 def test_search_string_no_matches(self):
     ps = PanScanner()
     matches = ps.search_string('there is no match :(')
     self.assertEqual(len(matches), 0)
Beispiel #16
0
 def test_search_string_ignore_test_card_numbers(self):
     ps = PanScanner(ignore_test_card_numbers=True)
     matches = ps.search_string('4111111111111111')
     self.assertEqual(len(matches), 0)
     matches = ps.search_string('4716334938933348')
     self.assertEqual(len(matches), 1)
Beispiel #17
0
 def test_search_string_one_match(self):
     ps = PanScanner()
     matches = ps.search_string('there is one match: 4111111111111111')
     self.assertEqual(len(matches), 1)
     self.assertEqual(matches[0].span(), (20, 36))
     self.assertEqual(matches[0].group(0), '4111111111111111')
Beispiel #18
0
 def test_search_string_one_match(self):
     ps = PanScanner()
     matches = ps.search_string('there is one match: 4111111111111111')
     self.assertEqual(len(matches), 1)
     self.assertEqual(matches[0].span(), (20, 36))
     self.assertEqual(matches[0].group(0), '4111111111111111')