blob: 240df4d45aab9e57b07edc8fb45e32749ce3ce75 [file] [log] [blame]
Ken'ichi Ohmichi01151e82016-06-10 11:19:52 -07001# Copyright 2016 NEC Corporation
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
16from tempest.common import image
17from tempest.lib.common import rest_client
18from tempest.tests import base
19
20
21class TestImage(base.TestCase):
22
23 def test_get_image_meta_from_headers(self):
24 resp = {
25 'x-image-meta-id': 'ea30c926-0629-4400-bb6e-f8a8da6a4e56',
26 'x-image-meta-owner': '8f421f9470e645b1b10f5d2db7804924',
27 'x-image-meta-status': 'queued',
28 'x-image-meta-name': 'New Http Image'
29 }
30 respbody = rest_client.ResponseBody(resp)
31 observed = image.get_image_meta_from_headers(respbody)
32
33 expected = {
34 'properties': {},
35 'id': 'ea30c926-0629-4400-bb6e-f8a8da6a4e56',
36 'owner': '8f421f9470e645b1b10f5d2db7804924',
37 'status': 'queued',
38 'name': 'New Http Image'
39 }
40 self.assertEqual(expected, observed)
Ken'ichi Ohmichi02bcdf32016-06-17 16:41:26 -070041
42 def test_image_meta_to_headers(self):
43 observed = image.image_meta_to_headers(
44 name='test',
45 container_format='wrong',
46 disk_format='vhd',
47 copy_from='http://localhost/images/10',
48 properties={'foo': 'bar'},
zhufl43488a52016-06-30 12:18:35 +080049 api={'abc': 'def'},
50 purge_props=True)
Ken'ichi Ohmichi02bcdf32016-06-17 16:41:26 -070051
52 expected = {
53 'x-image-meta-name': 'test',
54 'x-image-meta-container_format': 'wrong',
55 'x-image-meta-disk_format': 'vhd',
56 'x-glance-api-copy-from': 'http://localhost/images/10',
57 'x-image-meta-property-foo': 'bar',
zhufl43488a52016-06-30 12:18:35 +080058 'x-glance-api-property-abc': 'def',
59 'x-glance-registry-purge-props': True
Ken'ichi Ohmichi02bcdf32016-06-17 16:41:26 -070060 }
61 self.assertEqual(expected, observed)