~cloudbuilders/nova/os-keypair-integration

« back to all changes in this revision

Viewing changes to nova/tests/api/openstack/test_flavors.py

  • Committer: Jesse Andrews
  • Date: 2011-08-26 21:57:53 UTC
  • mfrom: (1455.1.45 nova)
  • Revision ID: anotherjesse@gmail.com-20110826215753-0sfp6dubujsl23wa
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
        self.assertEqual(res.status_int, 404)
139
139
 
140
140
    def test_get_flavor_by_id_v1_1(self):
141
 
        req = webob.Request.blank('/v1.1/flavors/12')
 
141
        req = webob.Request.blank('/v1.1/fake/flavors/12')
142
142
        req.environ['api.version'] = '1.1'
143
143
        res = req.get_response(fakes.wsgi_app())
144
144
        self.assertEqual(res.status_int, 200)
152
152
                "links": [
153
153
                    {
154
154
                        "rel": "self",
155
 
                        "href": "http://localhost/v1.1/flavors/12",
 
155
                        "href": "http://localhost/v1.1/fake/flavors/12",
156
156
                    },
157
157
                    {
158
158
                        "rel": "bookmark",
159
 
                        "href": "http://localhost/flavors/12",
 
159
                        "href": "http://localhost/fake/flavors/12",
160
160
                    },
161
161
                ],
162
162
            },
164
164
        self.assertEqual(flavor, expected)
165
165
 
166
166
    def test_get_flavor_list_v1_1(self):
167
 
        req = webob.Request.blank('/v1.1/flavors')
 
167
        req = webob.Request.blank('/v1.1/fake/flavors')
168
168
        req.environ['api.version'] = '1.1'
169
169
        res = req.get_response(fakes.wsgi_app())
170
170
        self.assertEqual(res.status_int, 200)
177
177
                    "links": [
178
178
                        {
179
179
                            "rel": "self",
180
 
                            "href": "http://localhost/v1.1/flavors/1",
 
180
                            "href": "http://localhost/v1.1/fake/flavors/1",
181
181
                        },
182
182
                        {
183
183
                            "rel": "bookmark",
184
 
                            "href": "http://localhost/flavors/1",
 
184
                            "href": "http://localhost/fake/flavors/1",
185
185
                        },
186
186
                    ],
187
187
                },
191
191
                    "links": [
192
192
                        {
193
193
                            "rel": "self",
194
 
                            "href": "http://localhost/v1.1/flavors/2",
 
194
                            "href": "http://localhost/v1.1/fake/flavors/2",
195
195
                        },
196
196
                        {
197
197
                            "rel": "bookmark",
198
 
                            "href": "http://localhost/flavors/2",
 
198
                            "href": "http://localhost/fake/flavors/2",
199
199
                        },
200
200
                    ],
201
201
                },
204
204
        self.assertEqual(flavor, expected)
205
205
 
206
206
    def test_get_flavor_list_detail_v1_1(self):
207
 
        req = webob.Request.blank('/v1.1/flavors/detail')
 
207
        req = webob.Request.blank('/v1.1/fake/flavors/detail')
208
208
        req.environ['api.version'] = '1.1'
209
209
        res = req.get_response(fakes.wsgi_app())
210
210
        self.assertEqual(res.status_int, 200)
219
219
                    "links": [
220
220
                        {
221
221
                            "rel": "self",
222
 
                            "href": "http://localhost/v1.1/flavors/1",
 
222
                            "href": "http://localhost/v1.1/fake/flavors/1",
223
223
                        },
224
224
                        {
225
225
                            "rel": "bookmark",
226
 
                            "href": "http://localhost/flavors/1",
 
226
                            "href": "http://localhost/fake/flavors/1",
227
227
                        },
228
228
                    ],
229
229
                },
235
235
                    "links": [
236
236
                        {
237
237
                            "rel": "self",
238
 
                            "href": "http://localhost/v1.1/flavors/2",
 
238
                            "href": "http://localhost/v1.1/fake/flavors/2",
239
239
                        },
240
240
                        {
241
241
                            "rel": "bookmark",
242
 
                            "href": "http://localhost/flavors/2",
 
242
                            "href": "http://localhost/fake/flavors/2",
243
243
                        },
244
244
                    ],
245
245
                },
252
252
            return {}
253
253
        self.stubs.Set(nova.db.api, "instance_type_get_all", _return_empty)
254
254
 
255
 
        req = webob.Request.blank('/v1.1/flavors')
 
255
        req = webob.Request.blank('/v1.1/fake/flavors')
256
256
        res = req.get_response(fakes.wsgi_app())
257
257
        self.assertEqual(res.status_int, 200)
258
258
        flavors = json.loads(res.body)["flavors"]
274
274
                "links": [
275
275
                    {
276
276
                        "rel": "self",
277
 
                        "href": "http://localhost/v1.1/flavors/12",
 
277
                        "href": "http://localhost/v1.1/fake/flavors/12",
278
278
                    },
279
279
                    {
280
280
                        "rel": "bookmark",
281
 
                        "href": "http://localhost/flavors/12",
 
281
                        "href": "http://localhost/fake/flavors/12",
282
282
                    },
283
283
                ],
284
284
            },
294
294
                name="asdf"
295
295
                ram="256"
296
296
                disk="10">
297
 
            <atom:link href="http://localhost/v1.1/flavors/12" rel="self"/>
298
 
            <atom:link href="http://localhost/flavors/12" rel="bookmark"/>
 
297
            <atom:link href="http://localhost/v1.1/fake/flavors/12"
 
298
                 rel="self"/>
 
299
            <atom:link href="http://localhost/fake/flavors/12"
 
300
                 rel="bookmark"/>
299
301
        </flavor>
300
302
        """.replace("  ", ""))
301
303
 
313
315
                "links": [
314
316
                    {
315
317
                        "rel": "self",
316
 
                        "href": "http://localhost/v1.1/flavors/12",
 
318
                        "href": "http://localhost/v1.1/fake/flavors/12",
317
319
                    },
318
320
                    {
319
321
                        "rel": "bookmark",
320
 
                        "href": "http://localhost/flavors/12",
 
322
                        "href": "http://localhost/fake/flavors/12",
321
323
                    },
322
324
                ],
323
325
            },
333
335
                name="asdf"
334
336
                ram="256"
335
337
                disk="10">
336
 
            <atom:link href="http://localhost/v1.1/flavors/12" rel="self"/>
337
 
            <atom:link href="http://localhost/flavors/12" rel="bookmark"/>
 
338
            <atom:link href="http://localhost/v1.1/fake/flavors/12"
 
339
                 rel="self"/>
 
340
            <atom:link href="http://localhost/fake/flavors/12"
 
341
                 rel="bookmark"/>
338
342
        </flavor>
339
343
        """.replace("  ", ""))
340
344
 
353
357
                    "links": [
354
358
                        {
355
359
                            "rel": "self",
356
 
                            "href": "http://localhost/v1.1/flavors/23",
 
360
                            "href": "http://localhost/v1.1/fake/flavors/23",
357
361
                        },
358
362
                        {
359
363
                            "rel": "bookmark",
360
 
                            "href": "http://localhost/flavors/23",
 
364
                            "href": "http://localhost/fake/flavors/23",
361
365
                        },
362
366
                    ],
363
367
                },        {
368
372
                    "links": [
369
373
                        {
370
374
                            "rel": "self",
371
 
                            "href": "http://localhost/v1.1/flavors/13",
 
375
                            "href": "http://localhost/v1.1/fake/flavors/13",
372
376
                        },
373
377
                        {
374
378
                            "rel": "bookmark",
375
 
                            "href": "http://localhost/flavors/13",
 
379
                            "href": "http://localhost/fake/flavors/13",
376
380
                        },
377
381
                    ],
378
382
                },
389
393
                    name="flavor 23"
390
394
                    ram="512"
391
395
                    disk="20">
392
 
                <atom:link href="http://localhost/v1.1/flavors/23" rel="self"/>
393
 
                <atom:link href="http://localhost/flavors/23" rel="bookmark"/>
 
396
                <atom:link href="http://localhost/v1.1/fake/flavors/23"
 
397
                     rel="self"/>
 
398
                <atom:link href="http://localhost/fake/flavors/23"
 
399
                     rel="bookmark"/>
394
400
            </flavor>
395
401
            <flavor id="13"
396
402
                    name="flavor 13"
397
403
                    ram="256"
398
404
                    disk="10">
399
 
                <atom:link href="http://localhost/v1.1/flavors/13" rel="self"/>
400
 
                <atom:link href="http://localhost/flavors/13" rel="bookmark"/>
 
405
                <atom:link href="http://localhost/v1.1/fake/flavors/13"
 
406
                     rel="self"/>
 
407
                <atom:link href="http://localhost/fake/flavors/13"
 
408
                     rel="bookmark"/>
401
409
            </flavor>
402
410
        </flavors>
403
411
        """.replace("  ", "") % locals())
417
425
                    "links": [
418
426
                        {
419
427
                            "rel": "self",
420
 
                            "href": "http://localhost/v1.1/flavors/23",
 
428
                            "href": "http://localhost/v1.1/fake/flavors/23",
421
429
                        },
422
430
                        {
423
431
                            "rel": "bookmark",
424
 
                            "href": "http://localhost/flavors/23",
 
432
                            "href": "http://localhost/fake/flavors/23",
425
433
                        },
426
434
                    ],
427
435
                },        {
432
440
                    "links": [
433
441
                        {
434
442
                            "rel": "self",
435
 
                            "href": "http://localhost/v1.1/flavors/13",
 
443
                            "href": "http://localhost/v1.1/fake/flavors/13",
436
444
                        },
437
445
                        {
438
446
                            "rel": "bookmark",
439
 
                            "href": "http://localhost/flavors/13",
 
447
                            "href": "http://localhost/fake/flavors/13",
440
448
                        },
441
449
                    ],
442
450
                },
450
458
        <flavors xmlns="http://docs.openstack.org/compute/api/v1.1"
451
459
                 xmlns:atom="http://www.w3.org/2005/Atom">
452
460
            <flavor id="23" name="flavor 23">
453
 
                <atom:link href="http://localhost/v1.1/flavors/23" rel="self"/>
454
 
                <atom:link href="http://localhost/flavors/23" rel="bookmark"/>
 
461
                <atom:link href="http://localhost/v1.1/fake/flavors/23"
 
462
                     rel="self"/>
 
463
                <atom:link href="http://localhost/fake/flavors/23"
 
464
                     rel="bookmark"/>
455
465
            </flavor>
456
466
            <flavor id="13" name="flavor 13">
457
 
                <atom:link href="http://localhost/v1.1/flavors/13" rel="self"/>
458
 
                <atom:link href="http://localhost/flavors/13" rel="bookmark"/>
 
467
                <atom:link href="http://localhost/v1.1/fake/flavors/13"
 
468
                     rel="self"/>
 
469
                <atom:link href="http://localhost/fake/flavors/13"
 
470
                     rel="bookmark"/>
459
471
            </flavor>
460
472
        </flavors>
461
473
        """.replace("  ", "") % locals())