예제 #1
0
    def test_timeout_no_update_available(self):
        """ Make sure that nothing happens (i.e. no status updates) when the
        updater indicates that there are no updates available. """

        mock_timer = self.mox.CreateMockAnything()

        self.mox.StubOutWithMock(StableUpdater, "__init__")
        self.mox.StubOutWithMock(StableUpdater, "check")
        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(False)

        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()
예제 #2
0
    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()
예제 #3
0
    def test_init_stable_update(self):
        """ Make sure that the StableUpdater is used if no updater is detailed.
        """

        self.mox.StubOutWithMock(StableUpdater, "__init__")

        StableUpdater.__init__(self.__repo, self.__remote_url)

        self.mox.ReplayAll()

        notifyer = UpdateNotifyer(self.__repo, self.__remote_url)
예제 #4
0
    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()
예제 #5
0
    def test_start(self):
        """ Make sure that a timer for the proper interval is started when the
        UpdateNotifyer.start method is called. """

        mock_timer = self.mox.CreateMockAnything()

        self.mox.StubOutWithMock(StableUpdater, "__init__")
        self.mox.StubOutWithMock(threading, "Timer")

        StableUpdater.__init__(self.__repo, self.__remote_url)

        threading.Timer(3600, mox.IgnoreArg()).AndReturn(mock_timer)
        mock_timer.start()

        self.mox.ReplayAll()

        notifyer = UpdateNotifyer(self.__repo, self.__remote_url)
        notifyer.start()
예제 #6
0
    def test_stop(self):
        """ Ensure that the timer is cancelled if UpdateNotifyer.stop is called.
        """

        mock_timer = self.mox.CreateMockAnything()

        self.mox.StubOutWithMock(StableUpdater, "__init__")
        self.mox.StubOutWithMock(threading, "Timer")

        StableUpdater.__init__(self.__repo, self.__remote_url)

        threading.Timer(3600, mox.IgnoreArg()).AndReturn(mock_timer)
        mock_timer.start()

        mock_timer.cancel()

        self.mox.ReplayAll()

        notifyer = UpdateNotifyer(self.__repo, self.__remote_url)
        notifyer.start()
        notifyer.stop()
예제 #7
0
    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()