Ken'ichi Ohmichi | 01151e8 | 2016-06-10 11:19:52 -0700 | [diff] [blame] | 1 | # 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 | |
| 16 | from tempest.common import image |
| 17 | from tempest.lib.common import rest_client |
| 18 | from tempest.tests import base |
| 19 | |
| 20 | |
| 21 | class 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 Ohmichi | 02bcdf3 | 2016-06-17 16:41:26 -0700 | [diff] [blame] | 41 | |
| 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'}, |
zhufl | 43488a5 | 2016-06-30 12:18:35 +0800 | [diff] [blame] | 49 | api={'abc': 'def'}, |
| 50 | purge_props=True) |
Ken'ichi Ohmichi | 02bcdf3 | 2016-06-17 16:41:26 -0700 | [diff] [blame] | 51 | |
| 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', |
zhufl | 43488a5 | 2016-06-30 12:18:35 +0800 | [diff] [blame] | 58 | 'x-glance-api-property-abc': 'def', |
| 59 | 'x-glance-registry-purge-props': True |
Ken'ichi Ohmichi | 02bcdf3 | 2016-06-17 16:41:26 -0700 | [diff] [blame] | 60 | } |
| 61 | self.assertEqual(expected, observed) |