Make test notifier useful

We need a way to query what notifications were sent to the test notifier
and later clear out that list.
This commit is contained in:
Mark McLoughlin 2013-06-24 12:39:52 +01:00
parent 75c376aab0
commit fc99d966af
1 changed files with 9 additions and 5 deletions

View File

@ -17,14 +17,18 @@
from oslo.messaging.notify import notifier
NOTIFICATIONS = []
def reset():
"Clear out the list of recorded notifications."
global NOTIFICATIONS
NOTIFICATIONS = []
class TestDriver(notifier._Driver):
"Store notifications in memory for test verification."
def __init__(self, conf, **kwargs):
super(TestDriver, self).__init__(conf, **kwargs)
self.notifications = []
def notify(self, ctxt, message, priority):
self.notifications.append(message)
NOTIFICATIONS.append((ctxt, message, priority))