def test_timeout_update_available(self): """ Make sure that we get a status update if the selected updater indicates that an update is available. """ mock_timer = self.mox.CreateMockAnything() self.mox.StubOutWithMock(StableUpdater, "__init__") self.mox.StubOutWithMock(StableUpdater, "check") self.mox.StubOutWithMock(StableUpdater, "get_update_version") self.mox.StubOutWithMock(threading, "Timer") self.mox.StubOutWithMock(threading.Thread, "start") self.mox.StubOutWithMock(Client, "change_status") StableUpdater.__init__(self.__repo, self.__remote_url) threading.Timer(3600, mox.IgnoreArg()).AndReturn(mock_timer) mock_timer.start() StableUpdater.check().AndReturn(True) StableUpdater.get_update_version().AndReturn("1.0") Client.change_status(mox.IgnoreArg()) threading.Timer(3600, mox.IgnoreArg()).AndReturn(mock_timer) mock_timer.start() self.mox.ReplayAll() notifyer = UpdateNotifyer(self.__repo, self.__remote_url) notifyer.start() notifyer.timeout()
def test_toggle_update_availability(self): """ Make sure that the update indicaiton is reset if an update all of a sudden is not available. """ mock_timer = self.mox.CreateMockAnything() self.mox.StubOutWithMock(StableUpdater, "__init__") self.mox.StubOutWithMock(StableUpdater, "check") self.mox.StubOutWithMock(StableUpdater, "get_update_version") self.mox.StubOutWithMock(threading, "Timer") self.mox.StubOutWithMock(threading.Thread, "start") self.mox.StubOutWithMock(Client, "change_status") StableUpdater.__init__(self.__repo, self.__remote_url) threading.Timer(3600, mox.IgnoreArg()).AndReturn(mock_timer) mock_timer.start() StableUpdater.check().AndReturn(True) StableUpdater.get_update_version().AndReturn("1.0") Client.change_status(mox.IgnoreArg()) threading.Timer(3600, mox.IgnoreArg()).AndReturn(mock_timer) mock_timer.start() StableUpdater.check().AndReturn(True) StableUpdater.get_update_version().AndReturn("1.0") threading.Timer(3600, mox.IgnoreArg()).AndReturn(mock_timer) mock_timer.start() StableUpdater.check().AndReturn(False) threading.Timer(3600, mox.IgnoreArg()).AndReturn(mock_timer) mock_timer.start() StableUpdater.check().AndReturn(True) Client.change_status(mox.IgnoreArg()) threading.Timer(3600, mox.IgnoreArg()).AndReturn(mock_timer) mock_timer.start() self.mox.ReplayAll() notifyer = UpdateNotifyer(self.__repo, self.__remote_url) notifyer.start() notifyer.timeout() notifyer.timeout() notifyer.timeout() notifyer.timeout()
def test_timeout_update_still_available(self): """ Make sure that we do not spam with software update notices. Once there has been an update notification, updates found thereafter should not be indicated. """ mock_timer = self.mox.CreateMockAnything() self.mox.StubOutWithMock(StableUpdater, "__init__") self.mox.StubOutWithMock(StableUpdater, "check") self.mox.StubOutWithMock(StableUpdater, "get_update_version") self.mox.StubOutWithMock(threading, "Timer") self.mox.StubOutWithMock(threading.Thread, "start") self.mox.StubOutWithMock(Client, "change_status") StableUpdater.__init__(self.__repo, self.__remote_url) threading.Timer(3600, mox.IgnoreArg()).AndReturn(mock_timer) mock_timer.start() StableUpdater.check().AndReturn(True) Client.change_status(mox.IgnoreArg()) threading.Timer(3600, mox.IgnoreArg()).AndReturn(mock_timer) mock_timer.start() StableUpdater.check().AndReturn(True) StableUpdater.get_update_version().AndReturn("1.0") threading.Timer(3600, mox.IgnoreArg()).AndReturn(mock_timer) mock_timer.start() self.mox.ReplayAll() notifyer = UpdateNotifyer(self.__repo, self.__remote_url) notifyer.start() notifyer.timeout() notifyer.timeout()