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

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-01-11 13:06:56 UTC
  • mto: This revision was merged to the branch mainline in revision 96.
  • Revision ID: package-import@ubuntu.com-20130111130656-z9mceux6qpkqomma
Tags: upstream-2013.1~g2
ImportĀ upstreamĀ versionĀ 2013.1~g2

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from nova.compute import api as compute_api
23
23
from nova.compute import instance_types
24
24
from nova import context
25
 
from nova import db
26
25
from nova.openstack.common import cfg
27
26
from nova.openstack.common import jsonutils
28
27
from nova.openstack.common import timeutils
32
31
from webob import exc
33
32
 
34
33
CONF = cfg.CONF
35
 
CONF.import_opt('password_length', 'nova.config')
 
34
CONF.import_opt('password_length', 'nova.utils')
36
35
 
37
36
FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
38
37
FAKE_UUID_A = '00000000-aaaa-aaaa-aaaa-000000000000'
290
289
        self.assertEqual(result['volumeAttachment']['id'],
291
290
            '00000000-aaaa-aaaa-aaaa-000000000000')
292
291
 
 
292
    def test_attach_volume_bad_id(self):
 
293
        self.stubs.Set(compute_api.API,
 
294
                       'attach_volume',
 
295
                       fake_attach_volume)
 
296
        attachments = volumes.VolumeAttachmentController()
 
297
 
 
298
        body = {
 
299
            'volumeAttachment': {
 
300
                'device': None,
 
301
                'volumeId': 'TESTVOLUME',
 
302
            }
 
303
        }
 
304
 
 
305
        req = fakes.HTTPRequest.blank('/v2/fake/os-volumes/attach')
 
306
        req.method = 'POST'
 
307
        req.content_type = 'application/json'
 
308
        req.body = jsonutils.dumps(body)
 
309
 
 
310
        self.assertRaises(webob.exc.HTTPBadRequest, attachments.create,
 
311
                          req, FAKE_UUID, body)
 
312
 
293
313
 
294
314
class VolumeSerializerTest(test.TestCase):
295
315
    def _verify_volume_attachment(self, attach, tree):