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

« back to all changes in this revision

Viewing changes to nova/tests/console/test_rpcapi.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:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2012, Red Hat, Inc.
 
4
#
 
5
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
6
#    not use this file except in compliance with the License. You may obtain
 
7
#    a copy of the License at
 
8
#
 
9
#         http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
11
#    Unless required by applicable law or agreed to in writing, software
 
12
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
13
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
14
#    License for the specific language governing permissions and limitations
 
15
#    under the License.
 
16
 
 
17
"""
 
18
Unit Tests for nova.console.rpcapi
 
19
"""
 
20
 
 
21
from nova.console import rpcapi as console_rpcapi
 
22
from nova import context
 
23
from nova import flags
 
24
from nova import rpc
 
25
from nova import test
 
26
 
 
27
 
 
28
FLAGS = flags.FLAGS
 
29
 
 
30
 
 
31
class ConsoleRpcAPITestCase(test.TestCase):
 
32
 
 
33
    def setUp(self):
 
34
        super(ConsoleRpcAPITestCase, self).setUp()
 
35
 
 
36
    def tearDown(self):
 
37
        super(ConsoleRpcAPITestCase, self).tearDown()
 
38
 
 
39
    def _test_console_api(self, method, **kwargs):
 
40
        ctxt = context.RequestContext('fake_user', 'fake_project')
 
41
        rpcapi = console_rpcapi.ConsoleAPI()
 
42
        expected_msg = rpcapi.make_msg(method, **kwargs)
 
43
        expected_msg['version'] = rpcapi.RPC_API_VERSION
 
44
 
 
45
        self.cast_ctxt = None
 
46
        self.cast_topic = None
 
47
        self.cast_msg = None
 
48
 
 
49
        def _fake_cast(_ctxt, _topic, _msg):
 
50
            self.cast_ctxt = _ctxt
 
51
            self.cast_topic = _topic
 
52
            self.cast_msg = _msg
 
53
 
 
54
        self.stubs.Set(rpc, 'cast', _fake_cast)
 
55
 
 
56
        getattr(rpcapi, method)(ctxt, **kwargs)
 
57
 
 
58
        self.assertEqual(self.cast_ctxt, ctxt)
 
59
        self.assertEqual(self.cast_topic, FLAGS.console_topic)
 
60
        self.assertEqual(self.cast_msg, expected_msg)
 
61
 
 
62
    def test_add_console(self):
 
63
        self._test_console_api('add_console', instance_id='i')
 
64
 
 
65
    def test_remove_console(self):
 
66
        self._test_console_api('remove_console', console_id='i')