Browse files

updatenotifier: Check updates later (in one week) if there are connec…

…tion problems
  • Loading branch information...
1 parent 386a48b commit 6d6832083e8ddecc68ea99d9578210431d9f1ac7 @mkorpela mkorpela committed Mar 1, 2012
Showing with 3 additions and 5 deletions.
  1. +1 −1 src/robotide/application/updatenotifier.py
  2. +2 −4 utest/application/test_updatenotifier.py
View
2 src/robotide/application/updatenotifier.py
@@ -47,6 +47,7 @@ def _should_check(self):
time.time() - self._settings.get(_LAST_UPDATE_CHECK_SETTING, 0) > self.SECONDS_IN_WEEK
def _is_new_version_available(self):
+ self._settings[_LAST_UPDATE_CHECK_SETTING] = time.time()
try:
self._newest_version = self._get_newest_version()
self._download_url = self._get_download_url(self._newest_version)
@@ -58,7 +59,6 @@ def _is_new_version_available(self):
# - Server fault message
# - Unexpected change in dataformat
return False
- self._settings[_LAST_UPDATE_CHECK_SETTING] = time.time()
return cmp_versions(self.VERSION, self._newest_version) == -1
def _get_newest_version(self):
View
6 utest/application/test_updatenotifier.py
@@ -93,26 +93,24 @@ def test_first_run_sets_settings_correctly_and_finds_an_update(self):
def test_checking_timeouts(self):
settings = self._settings()
- original_time = settings['last update check']
ctrl = UpdateNotifierController(settings)
def throwTimeoutError():
raise urllib2.URLError('timeout')
ctrl._get_newest_version = throwTimeoutError
ctrl.notify_update_if_needed(self._callback)
- self.assertEqual(original_time, settings['last update check'])
+ self.assertTrue(settings['last update check'] > time.time() - 1)
self.assertFalse(self._callback_called)
def test_download_url_checking_timeouts(self):
settings = self._settings()
- original_time = settings['last update check']
ctrl = UpdateNotifierController(settings)
ctrl.VERSION = '0'
ctrl._get_newest_version = lambda: '1'
def throwTimeoutError(*args):
raise urllib2.URLError('timeout')
ctrl._get_download_url = throwTimeoutError
ctrl.notify_update_if_needed(self._callback)
- self.assertEqual(original_time, settings['last update check'])
+ self.assertTrue(settings['last update check'] > time.time() - 1)
self.assertFalse(self._callback_called)
def test_server_returns_no_versions(self):

0 comments on commit 6d68320

Please sign in to comment.