def test_checking_timeouts(self): settings = self._settings() ctrl = UpdateNotifierController(settings) def throwTimeoutError(): raise urllib2.URLError('timeout') ctrl._get_newest_version = throwTimeoutError ctrl.notify_update_if_needed(self._callback) self.assertTrue(settings['last update check'] > time.time() - 1) self.assertFalse(self._callback_called)
def _update_notifier_controller(self, settings, current, new, url='some url'): ctrl = UpdateNotifierController(settings) ctrl.VERSION = current ctrl._get_newest_version = lambda: new ctrl._get_download_url = lambda v: url if v == new else None return ctrl