/usr/lib/python2.6/site-packages/openstack/tests/unit/image/v2
NameSizeModeActions
test_image.py33380644editdlrm
test_image.pyc34090644editdlrm
test_member.py19710644editdlrm
test_member.pyc20540644editdlrm
test_proxy.py69370644editdlrm
test_proxy.pyc91510644editdlrm
test_tag.py21850644editdlrm
test_tag.pyc28980644editdlrm
__init__.py00644editdlrm
__init__.pyc1630644editdlrm
Edit: /usr/lib/python2.6/site-packages/openstack/tests/unit/image/v2/test_image.py (3338B)
# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import datetime import mock import testtools from openstack.image.v2 import image IDENTIFIER = 'IDENTIFIER' EXAMPLE = { 'id': IDENTIFIER, 'checksum': '1', 'container_format': '2', 'created_at': '2015-03-09T12:14:57.233772', 'data': 'This is not an image', 'disk_format': '4', 'min_disk': 5, 'name': '6', 'owner': '7', 'properties': {'a': 'z', 'b': 'y', }, 'protected': False, 'status': '8', 'tags': ['g', 'h', 'i'], 'updated_at': '2015-03-09T12:15:57.233772', 'virtual_size': '10', 'visibility': '11' } class TestImage(testtools.TestCase): def test_basic(self): sot = image.Image() self.assertIsNone(sot.resource_key) self.assertEqual('images', sot.resources_key) self.assertEqual('/images', sot.base_path) self.assertEqual('image', sot.service.service_type) self.assertTrue(sot.allow_create) self.assertTrue(sot.allow_retrieve) self.assertTrue(sot.allow_update) self.assertTrue(sot.allow_delete) self.assertTrue(sot.allow_list) def test_make_it(self): sot = image.Image(EXAMPLE) self.assertEqual(IDENTIFIER, sot.id) self.assertEqual(EXAMPLE['checksum'], sot.checksum) self.assertEqual(EXAMPLE['container_format'], sot.container_format) dt = datetime.datetime(2015, 3, 9, 12, 14, 57, 233772).replace( tzinfo=None) self.assertEqual(dt, sot.created_at.replace(tzinfo=None)) self.assertEqual(EXAMPLE['disk_format'], sot.disk_format) self.assertEqual(EXAMPLE['min_disk'], sot.min_disk) self.assertEqual(EXAMPLE['name'], sot.name) self.assertEqual(EXAMPLE['owner'], sot.owner_id) self.assertEqual(EXAMPLE['properties'], sot.properties) self.assertFalse(sot.is_protected) self.assertEqual(EXAMPLE['status'], sot.status) self.assertEqual(EXAMPLE['tags'], sot.tags) dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace( tzinfo=None) self.assertEqual(dt, sot.updated_at.replace(tzinfo=None)) self.assertEqual(EXAMPLE['virtual_size'], sot.virtual_size) self.assertEqual(EXAMPLE['visibility'], sot.visibility) def test_import(self): self.resp = mock.Mock() self.resp.status_code = 204 self.sess = mock.Mock() self.sess.put = mock.Mock() self.sess.put.return_value = self.resp sot = image.Image(EXAMPLE) sot.upload_image(self.sess) headers = { 'Content-Type': 'application/octet-stream', 'Accept': '', } self.sess.put.assert_called_with( 'images/IDENTIFIER/file', endpoint_filter=sot.service, data=EXAMPLE['data'], headers=headers)