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:
parent
75c376aab0
commit
fc99d966af
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user