Revision dad1b874 kamaki/clients/image/test.py
b/kamaki/clients/image/test.py | ||
---|---|---|
290 | 290 |
for i in range(len(r)): |
291 | 291 |
self.assert_dicts_are_equal(r[i], example_images[i]) |
292 | 292 |
|
293 |
@patch('%s.put' % image_pkg, return_value=FR()) |
|
294 |
@patch('%s.set_header' % image_pkg) |
|
295 |
def test_update_image(self, set_header, put): |
|
296 |
FR.headers = 'some headers' |
|
297 |
hcnt = 0 |
|
298 |
for args in product( |
|
299 |
('some id', 'other id'), |
|
300 |
('image name', None), ('disk fmt', None), ('cnt format', None), |
|
301 |
('status', None), (True, False, None), ('owner id', None), |
|
302 |
(dict(k1='v1', k2='v2'), {})): |
|
303 |
r = self.client.update_image(*args[:-1], **args[-1]) |
|
304 |
(image_id, name, disk_format, container_format, |
|
305 |
status, public, owner_id, properties) = args |
|
306 |
self.assertEqual(r, FR.headers) |
|
307 |
header_calls = [] |
|
308 |
prf = 'X-Image-Meta-' |
|
309 |
if name: |
|
310 |
header_calls.append(call('%sName' % prf, name)) |
|
311 |
if disk_format: |
|
312 |
header_calls.append(call('%sDisk-Format' % prf, disk_format)) |
|
313 |
if container_format: |
|
314 |
header_calls.append( |
|
315 |
call('%sContainer-Format' % prf, container_format)) |
|
316 |
if status: |
|
317 |
header_calls.append(call('%sStatus' % prf, status)) |
|
318 |
if public is not None: |
|
319 |
header_calls.append(call('%sIs-Public' % prf, public)) |
|
320 |
if owner_id: |
|
321 |
header_calls.append(call('%sOwner' % prf, owner_id)) |
|
322 |
for k, v in properties.items(): |
|
323 |
header_calls.append(call('%sProperty-%s' % (prf, k), v)) |
|
324 |
self.assertEqual( |
|
325 |
sorted(set_header.mock_calls[hcnt:]), sorted(header_calls)) |
|
326 |
hcnt = len(set_header.mock_calls) |
|
327 |
self.assertEqual( |
|
328 |
put.mock_calls[-1], call('/images/%s' % image_id, success=200)) |
|
329 |
|
|
330 |
|
|
293 | 331 |
if __name__ == '__main__': |
294 | 332 |
from sys import argv |
295 | 333 |
from kamaki.clients.test import runTestCase |
Also available in: Unified diff