def patch_now(self):
     """
     Replace distro_tracker.core.utils.now() with a mocked version returning
     self.current_datetime
     """
     def get_datetime(*args, **kwargs):
         return self.current_datetime
     if not hasattr(self, 'current_datetime'):
         self.current_datetime = datetime.now()
     patcher = mock.patch('distro_tracker.core.utils.now')
     now = patcher.start()
     now.side_effect = get_datetime
     self.addCleanup(patcher.stop)
 def patch_vendor_call(self, return_value=None):
     patcher = mock.patch('distro_tracker.vendor.call')
     mocked = patcher.start()
     mocked.return_value = (return_value, return_value is not None)
     self.addCleanup(patcher.stop)
     return mocked
 def patch_forward(self):
     patcher = mock.patch('distro_tracker.mail.dispatch.forward')
     mocked = patcher.start()
     self.addCleanup(patcher.stop)
     return mocked
 def patch_mail_processor(self, new=mock.DEFAULT):
     process_method = 'distro_tracker.mail.processor.MailProcessor.process'
     patcher = mock.patch(process_method)
     mock_process = patcher.start()
     self.addCleanup(patcher.stop)
     return mock_process