def find_logged_contexts(self, raw, log_context):
     """Pull out strings from context-logging, to allow that to be tested."""
     obfuscate_util.find_phone_numbers(raw, log_context=log_context)
     self.assertEquals(self.mock_log.info.call_count, 1)
     args, _ = self.mock_log.info.call_args
     self.assertEquals(len(args), 5)
     self.assertEquals(args[1], self.TYPE)
     self.assertEquals(args[3], self.TEXT)
     return (args[2], args[4])
 def find_logged_contexts(self, raw, log_context):
     """Pull out strings from context-logging, to allow that to be tested."""
     obfuscate_util.find_phone_numbers(raw, log_context=log_context)
     self.assertEquals(self.mock_log.info.call_count, 1)
     args, _ = self.mock_log.info.call_args
     self.assertEquals(len(args), 5)
     self.assertEquals(args[1], self.TYPE)
     self.assertEquals(args[3], self.TEXT)
     return (args[2], args[4])
 def test_multiple_matches(self):
     raw = "{}{}{}{}{}{}{}".format(
         self.LEFT_CONTEXT, self.TEXT, self.RIGHT_CONTEXT, self.TEXT,
         self.RIGHT_CONTEXT, self.TEXT, self.LEFT_CONTEXT
     )
     obfuscate_util.find_phone_numbers(raw, log_context=10)
     self.assertEquals(self.mock_log.info.call_count, 3)
     args_list = self.mock_log.info.call_args_list
     # Create context lists in reverse so they can be popped.
     left_contexts = [self.RIGHT_CONTEXT, self.RIGHT_CONTEXT, self.LEFT_CONTEXT]
     right_contexts = list(reversed(left_contexts))
     for args, _ in args_list:
         self.assertEquals(len(args), 5)
         self.assertEquals(args[1], self.TYPE)
         self.assertEquals(args[3], self.TEXT)
         left = left_contexts.pop()
         right = right_contexts.pop()
         self.assertEquals(args[2], left[-10:])
         self.assertEquals(args[4], right[:10])
 def test_multiple_matches(self):
     raw = "{}{}{}{}{}{}{}".format(
         self.LEFT_CONTEXT, self.TEXT, self.RIGHT_CONTEXT, self.TEXT,
         self.RIGHT_CONTEXT, self.TEXT, self.LEFT_CONTEXT
     )
     obfuscate_util.find_phone_numbers(raw, log_context=10)
     self.assertEquals(self.mock_log.info.call_count, 3)
     args_list = self.mock_log.info.call_args_list
     # Create context lists in reverse so they can be popped.
     left_contexts = [self.RIGHT_CONTEXT, self.RIGHT_CONTEXT, self.LEFT_CONTEXT]
     right_contexts = list(reversed(left_contexts))
     for args, _ in args_list:
         self.assertEquals(len(args), 5)
         self.assertEquals(args[1], self.TYPE)
         self.assertEquals(args[3], self.TEXT)
         left = left_contexts.pop()
         right = right_contexts.pop()
         self.assertEquals(args[2], left[-10:])
         self.assertEquals(args[4], right[:10])
 def test_no_logging(self):
     raw = "{}{}{}".format(self.LEFT_CONTEXT, self.TEXT, self.RIGHT_CONTEXT)
     obfuscate_util.find_phone_numbers(raw)
     self.assertEquals(self.mock_log.info.call_count, 0)
 def test_find_phone_numbers_in_context(self, text, result):
     raw = self.SIMPLE_CONTEXT.format(text)
     expected = self.SIMPLE_CONTEXT.format(result)
     actual = obfuscate_util.find_phone_numbers(raw)
     self.assertEquals(expected, actual)
 def test_skip_non_phone_numbers(self, text):
     raw = self.SIMPLE_CONTEXT.format(text)
     result = obfuscate_util.find_phone_numbers(raw)
     self.assertEquals(raw, result)
 def test_find_simple_phone_numbers(self, text):
     raw = self.SIMPLE_CONTEXT.format(text)
     expected = self.SIMPLE_CONTEXT.format("<<PHONE_NUMBER>>")
     result = obfuscate_util.find_phone_numbers(raw)
     self.assertEquals(expected, result)
 def test_no_logging(self):
     raw = "{}{}{}".format(self.LEFT_CONTEXT, self.TEXT, self.RIGHT_CONTEXT)
     obfuscate_util.find_phone_numbers(raw)
     self.assertEquals(self.mock_log.info.call_count, 0)
 def test_find_phone_numbers_in_context(self, text, result):
     raw = self.SIMPLE_CONTEXT.format(text)
     expected = self.SIMPLE_CONTEXT.format(result)
     actual = obfuscate_util.find_phone_numbers(raw)
     self.assertEquals(expected, actual)
 def test_skip_non_phone_numbers(self, text):
     raw = self.SIMPLE_CONTEXT.format(text)
     result = obfuscate_util.find_phone_numbers(raw)
     self.assertEquals(raw, result)
 def test_find_simple_phone_numbers(self, text):
     raw = self.SIMPLE_CONTEXT.format(text)
     expected = self.SIMPLE_CONTEXT.format("<<PHONE_NUMBER>>")
     result = obfuscate_util.find_phone_numbers(raw)
     self.assertEquals(expected, result)