File: test_image.py

package info (click to toggle)
python-openstacksdk 0.9.5-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,264 kB
  • ctags: 5,542
  • sloc: python: 20,419; makefile: 133; sh: 46
file content (71 lines) | stat: -rw-r--r-- 2,624 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# 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 testtools

from openstack.image.v1 import image

IDENTIFIER = 'IDENTIFIER'
EXAMPLE = {
    'checksum': '1',
    'container_format': '2',
    'copy_from': '3',
    'disk_format': '4',
    'id': IDENTIFIER,
    'is_public': True,
    'location': '6',
    'min_disk': '7',
    'min_ram': '8',
    'name': '9',
    'owner': '10',
    'properties': '11',
    'protected': True,
    'size': '13',
    'status': '14',
    'created_at': '2015-03-09T12:14:57.233772',
    'updated_at': '2015-03-09T12:15:57.233772',
}


class TestImage(testtools.TestCase):

    def test_basic(self):
        sot = image.Image()
        self.assertEqual('image', 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(EXAMPLE['checksum'], sot.checksum)
        self.assertEqual(EXAMPLE['container_format'], sot.container_format)
        self.assertEqual(EXAMPLE['copy_from'], sot.copy_from)
        self.assertEqual(EXAMPLE['disk_format'], sot.disk_format)
        self.assertEqual(IDENTIFIER, sot.id)
        self.assertTrue(sot.is_public)
        self.assertEqual(EXAMPLE['location'], sot.location)
        self.assertEqual(EXAMPLE['min_disk'], sot.min_disk)
        self.assertEqual(EXAMPLE['min_ram'], sot.min_ram)
        self.assertEqual(EXAMPLE['name'], sot.name)
        self.assertEqual(EXAMPLE['owner'], sot.owner_id)
        self.assertEqual(EXAMPLE['properties'], sot.properties)
        self.assertTrue(sot.is_protected)
        self.assertEqual(EXAMPLE['size'], sot.size)
        self.assertEqual(EXAMPLE['status'], sot.status)
        self.assertEqual(EXAMPLE['created_at'], sot.created_at)
        self.assertEqual(EXAMPLE['updated_at'], sot.updated_at)