~ubuntu-cloud-archive/ubuntu/precise/nova/trunk

« back to all changes in this revision

Viewing changes to nova/tests/test_notifier.py

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-06-17 13:29:16 UTC
  • mto: (94.1.1 raring-proposed)
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: james.westby@ubuntu.com-20110617132916-u3vv6rxmtvnfn4cj
Tags: upstream-2011.3~d2~20110617.1191
ImportĀ upstreamĀ versionĀ 2011.3~d2~20110617.1191

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#    License for the specific language governing permissions and limitations
14
14
#    under the License.
15
15
 
 
16
import stubout
 
17
 
16
18
import nova
17
 
 
18
19
from nova import context
19
20
from nova import flags
 
21
from nova import log
20
22
from nova import rpc
21
23
import nova.notifier.api
22
24
from nova.notifier.api import notify
24
26
from nova.notifier import rabbit_notifier
25
27
from nova import test
26
28
 
27
 
import stubout
28
 
 
29
29
 
30
30
class NotifierTestCase(test.TestCase):
31
31
    """Test case for notifications"""
115
115
        notify('publisher_id',
116
116
                'event_type', 'DEBUG', dict(a=3))
117
117
        self.assertEqual(self.test_topic, 'testnotify.debug')
 
118
 
 
119
    def test_error_notification(self):
 
120
        self.stubs.Set(nova.flags.FLAGS, 'notification_driver',
 
121
            'nova.notifier.rabbit_notifier')
 
122
        self.stubs.Set(nova.flags.FLAGS, 'publish_errors', True)
 
123
        LOG = log.getLogger('nova')
 
124
        LOG.setup_from_flags()
 
125
        msgs = []
 
126
 
 
127
        def mock_cast(context, topic, data):
 
128
            msgs.append(data)
 
129
 
 
130
        self.stubs.Set(nova.rpc, 'cast', mock_cast)
 
131
        LOG.error('foo')
 
132
        self.assertEqual(1, len(msgs))
 
133
        msg = msgs[0]
 
134
        self.assertEqual(msg['event_type'], 'error_notification')
 
135
        self.assertEqual(msg['priority'], 'ERROR')
 
136
        self.assertEqual(msg['payload']['error'], 'foo')