Debian Codegraph @

glanceclient/tests/unit/v1/test_versions.py

raw symbols SCIP
1 # Copyright 2015 OpenStack Foundation
2 # Copyright 2015 Huawei Corp.
3 # All Rights Reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); you may
6 # not use this file except in compliance with the License. You may obtain
7 # a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 # License for the specific language governing permissions and limitations
15 # under the License.
16
17 import testtools
18
19 from glanceclient.tests import utils
20 import glanceclient.v1.versions
21
22
23 fixtures = {
24 '/versions': {
25 'GET': (
26 {},
27 {"versions": [
28 {
29 "status": "EXPERIMENTAL",
30 "id": "v3.0",
31 "links": [
32 {
33 "href": "http://10.229.45.145:9292/v3/",
34 "rel": "self"
35 }
36 ]
37 },
38 {
39 "status": "CURRENT",
40 "id": "v2.3",
41 "links": [
42 {
43 "href": "http://10.229.45.145:9292/v2/",
44 "rel": "self"
45 }
46 ]
47 },
48 {
49 "status": "SUPPORTED",
50 "id": "v1.0",
51 "links": [
52 {
53 "href": "http://10.229.45.145:9292/v1/",
54 "rel": "self"
55 }
56 ]
57 }
58 ]}
59 )
60 }
61 }
62
63
64 class TestVersions(testtools.TestCase):
65
66 def setUp(self):
67 super(TestVersions, self).setUp()
68 self.api = utils.FakeAPI(fixtures)
69 self.mgr = glanceclient.v1.versions.VersionManager(self.api)
70
71 def test_version_list(self):
72 versions = self.mgr.list()
73 expect = [('GET', '/versions', {}, None)]
74 self.assertEqual(expect, self.api.calls)
75 self.assertEqual(3, len(versions))
76 self.assertEqual('v3.0', versions[0]['id'])
77 self.assertEqual('EXPERIMENTAL', versions[0]['status'])
78 self.assertEqual([{"href": "http://10.229.45.145:9292/v3/",
79 "rel": "self"}], versions[0]['links'])