~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/tests/api/openstack/compute/test_extensions.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from nova.api.openstack import extensions as base_extensions
26
26
from nova.api.openstack import wsgi
27
27
from nova.api.openstack import xmlutil
28
 
from nova import flags
 
28
from nova.openstack.common import cfg
29
29
from nova.openstack.common import jsonutils
30
30
from nova import test
31
31
from nova.tests.api.openstack import fakes
32
 
 
33
 
 
34
 
FLAGS = flags.FLAGS
 
32
from nova.tests import matchers
 
33
 
 
34
CONF = cfg.CONF
 
35
CONF.import_opt('osapi_compute_extension', 'nova.config')
35
36
 
36
37
NS = "{http://docs.openstack.org/common/api/v1.0}"
37
38
ATOMNS = "{http://www.w3.org/2005/Atom}"
141
142
class ExtensionTestCase(test.TestCase):
142
143
    def setUp(self):
143
144
        super(ExtensionTestCase, self).setUp()
144
 
        ext_list = FLAGS.osapi_compute_extension[:]
 
145
        ext_list = CONF.osapi_compute_extension[:]
145
146
        fox = ('nova.tests.api.openstack.compute.extensions.'
146
147
               'foxinsocks.Foxinsocks')
147
148
        if fox not in ext_list:
166
167
            "DiskConfig",
167
168
            "ExtendedStatus",
168
169
            "ExtendedServerAttributes",
 
170
            "FixedIPs",
169
171
            "FlavorAccess",
170
172
            "FlavorDisabled",
171
173
            "FlavorExtraSpecs",
189
191
            "SecurityGroups",
190
192
            "ServerDiagnostics",
191
193
            "ServerStartStop",
 
194
            "Services",
192
195
            "SimpleTenantUsage",
193
196
            "UsedLimits",
194
197
            "UserData",
195
198
            "VirtualInterfaces",
196
199
            "Volumes",
197
 
            "VolumeTypes",
198
200
            ]
199
201
        self.ext_list.sort()
200
202
 
201
203
    def test_list_extensions_json(self):
202
 
        app = compute.APIRouter()
 
204
        app = compute.APIRouter(init_only=('extensions',))
203
205
        request = webob.Request.blank("/fake/extensions")
204
206
        response = request.get_response(app)
205
207
        self.assertEqual(200, response.status_int)
236
238
            self.assertEqual(output['extension']['alias'], ext['alias'])
237
239
 
238
240
    def test_get_extension_json(self):
239
 
        app = compute.APIRouter()
 
241
        app = compute.APIRouter(init_only=('extensions',))
240
242
        request = webob.Request.blank("/fake/extensions/FOXNSOX")
241
243
        response = request.get_response(app)
242
244
        self.assertEqual(200, response.status_int)
251
253
                "links": []})
252
254
 
253
255
    def test_get_non_existing_extension_json(self):
254
 
        app = compute.APIRouter()
 
256
        app = compute.APIRouter(init_only=('extensions',))
255
257
        request = webob.Request.blank("/fake/extensions/4")
256
258
        response = request.get_response(app)
257
259
        self.assertEqual(404, response.status_int)
258
260
 
259
261
    def test_list_extensions_xml(self):
260
 
        app = compute.APIRouter()
 
262
        app = compute.APIRouter(init_only=('servers', 'flavors', 'extensions'))
261
263
        request = webob.Request.blank("/fake/extensions")
262
264
        request.accept = "application/xml"
263
265
        response = request.get_response(app)
282
284
        xmlutil.validate_schema(root, 'extensions')
283
285
 
284
286
    def test_get_extension_xml(self):
285
 
        app = compute.APIRouter()
 
287
        app = compute.APIRouter(init_only=('servers', 'flavors', 'extensions'))
286
288
        request = webob.Request.blank("/fake/extensions/FOXNSOX")
287
289
        request.accept = "application/xml"
288
290
        response = request.get_response(app)
348
350
                "code": 400
349
351
            }
350
352
        }
351
 
        self.assertDictMatch(expected, body)
 
353
        self.assertThat(expected, matchers.DictMatches(body))
352
354
 
353
355
    def test_non_exist_resource(self):
354
356
        res_ext = base_extensions.ResourceExtension('tweedles',
366
368
                "code": 404
367
369
            }
368
370
        }
369
 
        self.assertDictMatch(expected, body)
 
371
        self.assertThat(expected, matchers.DictMatches(body))
370
372
 
371
373
 
372
374
class InvalidExtension(object):
398
400
class ActionExtensionTest(ExtensionTestCase):
399
401
 
400
402
    def _send_server_action_request(self, url, body):
401
 
        app = compute.APIRouter()
 
403
        app = compute.APIRouter(init_only=('servers',))
402
404
        request = webob.Request.blank(url)
403
405
        request.method = 'POST'
404
406
        request.content_type = 'application/json'
431
433
                "code": 400
432
434
            }
433
435
        }
434
 
        self.assertDictMatch(expected, body)
 
436
        self.assertThat(expected, matchers.DictMatches(body))
435
437
 
436
438
    def test_non_exist_action(self):
437
439
        body = dict(blah=dict(name="test"))
452
454
                "code": 400
453
455
            }
454
456
        }
455
 
        self.assertDictMatch(expected, body)
 
457
        self.assertThat(expected, matchers.DictMatches(body))
456
458
 
457
459
 
458
460
class RequestExtensionTest(ExtensionTestCase):
478
480
 
479
481
    def test_get_resources_with_mgr(self):
480
482
 
481
 
        app = fakes.wsgi_app()
 
483
        app = fakes.wsgi_app(init_only=('flavors',))
482
484
        request = webob.Request.blank("/v2/fake/flavors/1?chewing=newblue")
483
485
        request.environ['api.version'] = '2'
484
486
        response = request.get_response(app)
667
669
                    self.assertEqual(link_nodes[i].get(key), value)
668
670
 
669
671
        xmlutil.validate_schema(root, 'extensions')
 
672
 
 
673
 
 
674
class ExtensionControllerIdFormatTest(test.TestCase):
 
675
 
 
676
    def _bounce_id(self, test_id):
 
677
 
 
678
        class BounceController(object):
 
679
            def show(self, req, id):
 
680
                return id
 
681
        res_ext = base_extensions.ResourceExtension('bounce',
 
682
                                                    BounceController())
 
683
        manager = StubExtensionManager(res_ext)
 
684
        app = compute.APIRouter(manager)
 
685
        request = webob.Request.blank("/fake/bounce/%s" % test_id)
 
686
        response = request.get_response(app)
 
687
        return response.body
 
688
 
 
689
    def test_id_with_xml_format(self):
 
690
        result = self._bounce_id('foo.xml')
 
691
        self.assertEqual(result, 'foo')
 
692
 
 
693
    def test_id_with_json_format(self):
 
694
        result = self._bounce_id('foo.json')
 
695
        self.assertEqual(result, 'foo')
 
696
 
 
697
    def test_id_with_bad_format(self):
 
698
        result = self._bounce_id('foo.bad')
 
699
        self.assertEqual(result, 'foo.bad')