~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/tests/notifier/test_capacity_notifier.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
import nova.db.api
17
17
from nova.notifier import capacity_notifier as cn
 
18
from nova.openstack.common import jsonutils
18
19
from nova import test
19
 
from nova import utils
20
20
 
21
21
 
22
22
class CapacityNotifierTestCase(test.TestCase):
24
24
 
25
25
    def _make_msg(self, host, event):
26
26
        usage_info = dict(memory_mb=123, disk_gb=456)
27
 
        payload = utils.to_primitive(usage_info, convert_instances=True)
 
27
        payload = jsonutils.to_primitive(usage_info, convert_instances=True)
28
28
        return dict(
29
29
            publisher_id="compute.%s" % host,
30
30
            event_type="compute.instance.%s" % event,
34
34
    def test_event_type(self):
35
35
        msg = self._make_msg("myhost", "mymethod")
36
36
        msg['event_type'] = 'random'
37
 
        self.assertFalse(cn.notify(msg))
 
37
        self.assertFalse(cn.notify(None, msg))
38
38
 
39
39
    def test_bad_event_suffix(self):
40
40
        msg = self._make_msg("myhost", "mymethod.badsuffix")
41
 
        self.assertFalse(cn.notify(msg))
 
41
        self.assertFalse(cn.notify(None, msg))
42
42
 
43
43
    def test_bad_publisher_id(self):
44
44
        msg = self._make_msg("myhost", "mymethod.start")
45
45
        msg['publisher_id'] = 'badpublisher'
46
 
        self.assertFalse(cn.notify(msg))
 
46
        self.assertFalse(cn.notify(None, msg))
47
47
 
48
48
    def test_update_called(self):
49
49
        def _verify_called(host, context, free_ram_mb_delta,
56
56
        self.stubs.Set(nova.db.api, "compute_node_utilization_update",
57
57
                       _verify_called)
58
58
        msg = self._make_msg("myhost", "delete.end")
59
 
        self.assertTrue(cn.notify(msg))
 
59
        self.assertTrue(cn.notify(None, msg))