Revision e2c53122
b/kamaki/clients/test/image.py | ||
---|---|---|
67 | 67 |
"id": "5963020b-ab74-4e11-bc59-90c494bbdedb", |
68 | 68 |
"size": 2589802496}] |
69 | 69 |
|
70 |
example_images_detailed = [ |
|
71 |
{ |
|
72 |
"status": "available", |
|
73 |
"name": "Archlinux", |
|
74 |
"checksum": "1a126aad07475b43cc1959b446344211be13974", |
|
75 |
"created_at": "2013-01-28 22:44:54", |
|
76 |
"disk_format": "diskdump", |
|
77 |
"updated_at": "2013-01-28 22:44:55", |
|
78 |
"properties": { |
|
79 |
"partition_table": "msdos", |
|
80 |
"osfamily": "linux", |
|
81 |
"users": "root", |
|
82 |
"exclude_task_assignhostname": "yes", |
|
83 |
"os": "archlinux", |
|
84 |
"root_partition": "1", |
|
85 |
"description": "Archlinux base install 2012.12.01"}, |
|
86 |
"location": "pithos://us3r-I6E-1d/images/archlinux.12.2012", |
|
87 |
"container_format": "bare", |
|
88 |
"owner": "user163@mail.example.com", |
|
89 |
"is_public": True, |
|
90 |
"deleted_at": "", |
|
91 |
"id": "b4713f20-3a41-4eaf-81ae-88698c18b3e8", |
|
92 |
"size": 752782848}, |
|
93 |
{ |
|
94 |
"status": "available", |
|
95 |
"name": "Debian_Wheezy_Base", |
|
96 |
"checksum": "8f96e73ba8886a05de6f9b3705c981", |
|
97 |
"created_at": "2013-01-29 16:41:13", |
|
98 |
"disk_format": "diskdump", |
|
99 |
"updated_at": "2013-01-29 16:41:14", |
|
100 |
"properties": { |
|
101 |
"partition_table": "msdos", |
|
102 |
"osfamily": "linux", |
|
103 |
"users": "root", |
|
104 |
"swap": "5:259", |
|
105 |
"os": "debian", |
|
106 |
"root_partition": "1", |
|
107 |
"description": "Debian7.0(Wheezy)Base"}, |
|
108 |
"location": "pithos://us3r-EO2-1d/images/Deb_Whz201301291840.diskdump", |
|
109 |
"container_format": "bare", |
|
110 |
"owner": "user302@mail.example.com", |
|
111 |
"is_public": True, |
|
112 |
"deleted_at": "", |
|
113 |
"id": "1f8454f0-8e3e-4b6c-ab8e-5236b728dffe", |
|
114 |
"size": 795107328}, |
|
115 |
{ |
|
116 |
"status": "available", |
|
117 |
"name": "maelstrom", |
|
118 |
"checksum": "b202b8c7030cb22f896c6664ac", |
|
119 |
"created_at": "2013-02-13 10:07:42", |
|
120 |
"disk_format": "diskdump", |
|
121 |
"updated_at": "2013-02-13 10:07:44", |
|
122 |
"properties": { |
|
123 |
"partition_table": "msdos", |
|
124 |
"osfamily": "linux", |
|
125 |
"description": "Ubuntu 12.04.1 LTS", |
|
126 |
"os": "ubuntu", |
|
127 |
"root_partition": "1", |
|
128 |
"users": "user"}, |
|
129 |
"location": "pithos://us3r-@r3n@-1d/images/mls-201302131203.diskdump", |
|
130 |
"container_format": "bare", |
|
131 |
"owner": "user3@mail.example.com", |
|
132 |
"is_public": True, |
|
133 |
"deleted_at": "", |
|
134 |
"id": "0fb03e45-7d5a-4515-bd4e-e6bbf6457f06", |
|
135 |
"size": 2583195648}, |
|
136 |
{ |
|
137 |
"status": "available", |
|
138 |
"name": "Gardenia", |
|
139 |
"checksum": "06d3099815d1f6fada91e80107638b882", |
|
140 |
"created_at": "2013-02-13 12:35:21", |
|
141 |
"disk_format": "diskdump", |
|
142 |
"updated_at": "2013-02-13 12:35:23", |
|
143 |
"properties": { |
|
144 |
"partition_table": "msdos", |
|
145 |
"osfamily": "linux", |
|
146 |
"description": "Ubuntu 12.04.2 LTS", |
|
147 |
"os": "ubuntu", |
|
148 |
"root_partition": "1", |
|
149 |
"users": "user"}, |
|
150 |
"location": "pithos://us3r-E-1d/images/Gardenia-201302131431.diskdump", |
|
151 |
"container_format": "bare", |
|
152 |
"owner": "user3@mail.example.com", |
|
153 |
"is_public": True, |
|
154 |
"deleted_at": "", |
|
155 |
"id": "5963020b-ab74-4e11-bc59-90c494bbdedb", |
|
156 |
"size": 2589802496}] |
|
157 |
|
|
70 | 158 |
class Image(TestCase): |
71 | 159 |
|
72 | 160 |
class FR(object): |
... | ... | |
119 | 207 |
self.assertEqual(self.client.http_client.url, self.url) |
120 | 208 |
self.assertEqual(self.client.http_client.path, '/images/') |
121 | 209 |
|
210 |
self.FR.json = example_images_detailed |
|
122 | 211 |
r = self.client.list_public(detail=True) |
123 | 212 |
self.assertEqual(self.client.http_client.url, self.url) |
124 | 213 |
self.assertEqual(self.client.http_client.path, '/images/detail') |
214 |
for i in range(len(r)): |
|
215 |
self.assert_dicts_are_deeply_equal( |
|
216 |
r[i], |
|
217 |
example_images_detailed[i]) |
|
125 | 218 |
|
126 | 219 |
size_max = 1000000000 |
127 | 220 |
r = self.client.list_public(filters=dict(size_max=size_max)) |
... | ... | |
130 | 223 |
self.assertEqual(self.client.http_client.url, self.url) |
131 | 224 |
self.assertEqual(self.client.http_client.path, '/images/') |
132 | 225 |
|
133 |
""" |
|
134 | 226 |
def test_get_meta(self): |
135 |
""Test get_meta"" |
|
136 |
self._test_get_meta() |
|
137 |
|
|
138 |
def _test_get_meta(self): |
|
139 |
r = self.client.get_meta(self['image', 'id']) |
|
140 |
self.assertEqual(r['id'], self['image', 'id']) |
|
141 |
for term in ( |
|
142 |
'status', |
|
143 |
'name', |
|
144 |
'checksum', |
|
145 |
'updated-at', |
|
146 |
'created-at', |
|
147 |
'deleted-at', |
|
148 |
'location', |
|
149 |
'is-public', |
|
150 |
'owner', |
|
151 |
'disk-format', |
|
152 |
'size', |
|
153 |
'container-format'): |
|
154 |
self.assertTrue(term in r) |
|
155 |
for interm in ( |
|
156 |
'kernel', |
|
157 |
'osfamily', |
|
158 |
'users', |
|
159 |
'gui', 'sortorder', |
|
160 |
'root-partition', |
|
161 |
'os', |
|
162 |
'description'): |
|
163 |
self.assertTrue(interm in r['properties']) |
|
227 |
img0 = example_images[0] |
|
228 |
self.FR.json = img0 |
|
229 |
img0_headers = {} |
|
230 |
for k, v in example_images_detailed[0].items(): |
|
231 |
img0_headers['x-image-meta-%s' % k] = v |
|
232 |
self.FR.headers = img0_headers |
|
233 |
with patch.object(self.C, 'perform_request', return_value=self.FR()): |
|
234 |
r = self.client.get_meta(img0['id']) |
|
235 |
self.assertEqual(self.client.http_client.url, self.url) |
|
236 |
expected_path = '/images/%s' % img0['id'] |
|
237 |
self.assertEqual(self.client.http_client.path, expected_path) |
|
164 | 238 |
|
239 |
self.assertEqual(r['id'], img0['id']) |
|
240 |
self.assert_dicts_are_deeply_equal(r, example_images_detailed[0]) |
|
241 |
|
|
242 |
""" |
|
165 | 243 |
def test_register(self): |
166 | 244 |
""Test register"" |
167 | 245 |
self._prepare_img() |
Also available in: Unified diff