def test_notify_on_bleeding_edge_no_interval(self): """ Make sure that the default interval is used for the BleedingEdgeUpdater, as for the StableUpdater. """ mock_file = self.mox.CreateMockAnything() mock_timer = self.mox.CreateMockAnything() mock_file.closed = False mock_file.name = "foobar" action, model = ("notify", "bleeding") self.mox.StubOutWithMock(SafeConfigParser, "get") self.mox.StubOutWithMock(BleedingEdgeUpdater, "__init__") self.mox.StubOutWithMock(threading, "Timer") config = ConfigurationParser() config.parse(mock_file) config.get("updates", "action").AndReturn(action) config.get("updates", "model").AndReturn(model) config.get("updates", "interval").AndRaise(NoOptionError("updates", "interval")) BleedingEdgeUpdater.__init__(REPO, construct_url_for_head_commit()) threading.Timer(DEFAULT_INTERVAL, mox.IgnoreArg()).AndReturn(mock_timer) mock_timer.start() self.mox.ReplayAll() update_handler = get_update_handler() update_handler.start() self.assertTrue(isinstance(update_handler, UpdateNotifyer))
def test_notify_on_bleeding_edge_interval(self): """ Make sure that a BleedingEdgeUpdater is constructed if the configuration details it. """ mock_file = self.mox.CreateMockAnything() mock_timer = self.mox.CreateMockAnything() mock_file.closed = False mock_file.name = "foobar" action, model, interval = ("notify", "bleeding", "43200") self.mox.StubOutWithMock(SafeConfigParser, "get") self.mox.StubOutWithMock(BleedingEdgeUpdater, "__init__") self.mox.StubOutWithMock(threading, "Timer") config = ConfigurationParser() config.parse(mock_file) config.get("updates", "action").AndReturn(action) config.get("updates", "model").AndReturn(model) config.get("updates", "interval").AndReturn(interval) BleedingEdgeUpdater.__init__(REPO, construct_url_for_head_commit()) threading.Timer(int(interval), mox.IgnoreArg()).AndReturn(mock_timer) mock_timer.start() self.mox.ReplayAll() update_handler = get_update_handler() update_handler.start() self.assertTrue(isinstance(update_handler, UpdateNotifyer))