def test_run_apt_update_runs_interval_expired(self):
"""
L{PackageReporter.run_apt_update} runs if both apt-update and
update-notifier-common stamp files are present and the time
interval has passed.
"""
self.reporter._apt_sources_have_changed = lambda: False
expired_time = time.time() - self.config.apt_update_interval - 1
# The interval for both stamp files is expired.
self.makeFile("", path=self.config.update_stamp_filename)
os.utime(
self.config.update_stamp_filename, (expired_time, expired_time))
self.reporter.update_notifier_stamp = self.makeFile("")
os.utime(
self.reporter.update_notifier_stamp, (expired_time, expired_time))
message_store = self.broker_service.message_store
message_store.set_accepted_types(["package-reporter-result"])
self._make_fake_apt_update(err="message")
deferred = Deferred()
def do_test():
result = self.reporter.run_apt_update()
def callback(ignore):
self.assertMessages(
message_store.get_pending_messages(),
[{"type": "package-reporter-result",
"report-timestamp": 0.0, "code": 0, "err": u"message"}])
result.addCallback(callback)
self.reactor.advance(0)
result.chainDeferred(deferred)
reactor.callWhenRunning(do_test)
return deferred
评论列表
文章目录