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

« back to all changes in this revision

Viewing changes to nova/tests/api/openstack/compute/contrib/test_config_drive.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:
 
1
# Copyright 2012 OpenStack LLC.
 
2
# All Rights Reserved.
 
3
#
 
4
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
5
#    not use this file except in compliance with the License. You may obtain
 
6
#    a copy of the License at
 
7
#
 
8
#         http://www.apache.org/licenses/LICENSE-2.0
 
9
#
 
10
#    Unless required by applicable law or agreed to in writing, software
 
11
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
12
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
13
#    License for the specific language governing permissions and limitations
 
14
#    under the License.
 
15
 
 
16
import webob
 
17
 
 
18
from nova.api.openstack.compute.contrib import config_drive
 
19
from nova import db
 
20
from nova.openstack.common import jsonutils
 
21
from nova import test
 
22
from nova.tests.api.openstack import fakes
 
23
import nova.tests.image.fake
 
24
 
 
25
 
 
26
class ConfigDriveTest(test.TestCase):
 
27
 
 
28
    def setUp(self):
 
29
        super(ConfigDriveTest, self).setUp()
 
30
        self.Controller = config_drive.Controller()
 
31
        fakes.stub_out_networking(self.stubs)
 
32
        fakes.stub_out_rate_limiting(self.stubs)
 
33
        nova.tests.image.fake.stub_out_image_service(self.stubs)
 
34
 
 
35
    def test_show(self):
 
36
        self.stubs.Set(db, 'instance_get',
 
37
                        fakes.fake_instance_get())
 
38
        req = webob.Request.blank('/v2/fake/servers/1')
 
39
        req.headers['Content-Type'] = 'application/json'
 
40
        response = req.get_response(fakes.wsgi_app())
 
41
        self.assertEquals(response.status_int, 200)
 
42
        res_dict = jsonutils.loads(response.body)
 
43
        self.assertTrue('config_drive' in res_dict['server'])
 
44
 
 
45
    def test_detail_servers(self):
 
46
        self.stubs.Set(db, 'instance_get',
 
47
                        fakes.fake_instance_get())
 
48
        req = fakes.HTTPRequest.blank('/v2/fake/servers/detail')
 
49
        res = req.get_response(fakes.wsgi_app())
 
50
        server_dicts = jsonutils.loads(res.body)['servers']
 
51
        for server_dict in server_dicts:
 
52
            self.asserTrue('config_drive' in server_dict)