~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/tests/api/openstack/compute/contrib/test_consoles.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-08-16 14:04:11 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: package-import@ubuntu.com-20120816140411-0mr4n241wmk30t9l
Tags: upstream-2012.2~f3
ImportĀ upstreamĀ versionĀ 2012.2~f3

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    raise exception.ConsoleTypeInvalid(console_type=_console_type)
32
32
 
33
33
 
 
34
def fake_get_vnc_console_not_ready(self, _context, instance, _console_type):
 
35
    raise exception.InstanceNotReady(instance_id=instance["uuid"])
 
36
 
 
37
 
34
38
def fake_get_vnc_console_not_found(self, _context, instance, _console_type):
35
39
    raise exception.InstanceNotFound(instance_id=instance["uuid"])
36
40
 
64
68
        self.assertEqual(output,
65
69
            {u'console': {u'url': u'http://fake', u'type': u'novnc'}})
66
70
 
 
71
    def test_get_vnc_console_not_ready(self):
 
72
        self.stubs.Set(compute.API, 'get_vnc_console',
 
73
                       fake_get_vnc_console_not_ready)
 
74
        body = {'os-getVNCConsole': {'type': 'novnc'}}
 
75
        req = webob.Request.blank('/v2/fake/servers/1/action')
 
76
        req.method = "POST"
 
77
        req.body = jsonutils.dumps(body)
 
78
        req.headers["content-type"] = "application/json"
 
79
 
 
80
        res = req.get_response(fakes.wsgi_app())
 
81
        output = jsonutils.loads(res.body)
 
82
        self.assertEqual(res.status_int, 409)
 
83
 
67
84
    def test_get_vnc_console_no_type(self):
68
 
        self.stubs.Set(compute.API, 'get', fake_get)
69
85
        self.stubs.Set(compute.API, 'get_vnc_console',
70
86
                       fake_get_vnc_console_invalid_type)
71
87
        body = {'os-getVNCConsole': {}}
90
106
 
91
107
    def test_get_vnc_console_no_instance_on_console_get(self):
92
108
        self.stubs.Set(compute.API, 'get_vnc_console',
93
 
            fake_get_vnc_console_not_found)
 
109
                       fake_get_vnc_console_not_found)
94
110
        body = {'os-getVNCConsole': {'type': 'novnc'}}
95
111
        req = webob.Request.blank('/v2/fake/servers/1/action')
96
112
        req.method = "POST"
101
117
        self.assertEqual(res.status_int, 404)
102
118
 
103
119
    def test_get_vnc_console_invalid_type(self):
104
 
        self.stubs.Set(compute.API, 'get', fake_get)
105
120
        body = {'os-getVNCConsole': {'type': 'invalid'}}
106
121
        self.stubs.Set(compute.API, 'get_vnc_console',
107
122
                       fake_get_vnc_console_invalid_type)