Revision 776b275c kamaki/clients/pithos/test.py
b/kamaki/clients/pithos/test.py | ||
---|---|---|
242 | 242 |
pm = pm[:-2] |
243 | 243 |
self.client.account_post(*(pm + args), **kwargs) |
244 | 244 |
upd = pm[0] |
245 |
self.assertEqual(SP.mock_calls[-1], call('update', iff=upd)) |
|
245 |
self.assertEqual(SP.mock_calls[-1], call('update', '', iff=upd))
|
|
246 | 246 |
expected = [] |
247 | 247 |
if pm[1]: |
248 | 248 |
expected += [ |
... | ... | |
369 | 369 |
self.client.container_post(*(pm + args), **kwargs) |
370 | 370 |
upd, frmt = pm[:2] |
371 | 371 |
self.assertEqual(SP.mock_calls[-2:], [ |
372 |
call('update', iff=upd), |
|
372 |
call('update', '', iff=upd),
|
|
373 | 373 |
call('format', frmt, iff=frmt)]) |
374 | 374 |
qta, vrs, metas, ctype, clen, trenc = pm[2:] |
375 | 375 |
prfx = 'X-Container-Meta-' |
... | ... | |
637 | 637 |
if pval: |
638 | 638 |
perm_str += ';' if perm_str else '' |
639 | 639 |
perm_str += '%s=%s' % (ptype, ','.join(pval)) |
640 |
exp += [call('X-Object-Sharing', perm_str)] |
|
640 |
exp += [call('X-Object-Sharing', perm_str, iff=perms)] |
|
641 |
else: |
|
642 |
exp += [call('X-Object-Sharing', '', iff={})] |
|
641 | 643 |
exp += [call('X-Object-Public', public, public is not None)] |
642 | 644 |
for k, v in metas.items(): |
643 | 645 |
exp += [call('X-Object-Meta-%s' % k, v)] |
... | ... | |
674 | 676 |
format, update = pm[:2] |
675 | 677 |
self.assertEqual(SP.mock_calls[-2:], [ |
676 | 678 |
call('format', format, iff=format), |
677 |
call('update', iff=update)]) |
|
679 |
call('update', '', iff=update)])
|
|
678 | 680 |
( |
679 | 681 |
im, inm, clen, ctype, crng, trenc, cenc, |
680 | 682 |
condis, srcobj, srcacc, srcvrs, obytes, mnfs) = terms |
... | ... | |
699 | 701 |
if pval: |
700 | 702 |
perm_str += ';' if perm_str else '' |
701 | 703 |
perm_str += '%s=%s' % (ptype, ','.join(pval)) |
702 |
exp += [call('X-Object-Sharing', perm_str)] |
|
704 |
exp += [call('X-Object-Sharing', perm_str, iff=perms)] |
|
705 |
else: |
|
706 |
exp += [call('X-Object-Sharing', '', iff={})] |
|
703 | 707 |
exp += [call('X-Object-Public', public, public is not None)] |
704 | 708 |
for k, v in metas.items(): |
705 | 709 |
exp += [call('X-Object-Meta-%s' % k, v)] |
... | ... | |
737 | 741 |
**kwargs)) |
738 | 742 |
|
739 | 743 |
|
744 |
class PithosMethods(TestCase): |
|
745 |
|
|
746 |
def test__range_up(self): |
|
747 |
from kamaki.clients.pithos import _range_up |
|
748 |
for args, expected in ( |
|
749 |
((0, 100, 1000, '10'), '0-10'), |
|
750 |
((0, 100, 1000, '-10'), ''), |
|
751 |
((900, 1000, 1000, '-10'), '990-1000'), |
|
752 |
((150, 250, 1000, '10'), ''), |
|
753 |
((10, 200, 1000, '130-170'), '130-170'), |
|
754 |
((150, 200, 1000, '130-170'), '150-170'), |
|
755 |
((100, 150, 1000, '130-170'), '130-150'), |
|
756 |
((200, 250, 1000, '130-170'), ''), |
|
757 |
((100, 250, 1000, '30-170,200-270'), '100-170,200-250'), |
|
758 |
((40, 950, 1000, '-170,200-270,50',), '830-950,200-270,40-50'), |
|
759 |
((740, 900, 1000, '-170,200-270,50',), '830-900'), |
|
760 |
((42, 333, 800, '100,50-200,-600',), '42-100,50-200,200-333')): |
|
761 |
self.assertEqual(_range_up(*args), expected) |
|
762 |
|
|
763 |
|
|
740 | 764 |
class PithosClient(TestCase): |
741 | 765 |
|
742 | 766 |
files = [] |
... | ... | |
1379 | 1403 |
self.assertEqual(r, {}) |
1380 | 1404 |
exp_args = dict( |
1381 | 1405 |
hashmap=True, |
1382 |
data_range=None, |
|
1383 | 1406 |
version=None, |
1384 | 1407 |
if_etag_match=None, |
1385 | 1408 |
if_etag_not_match=None, |
... | ... | |
1390 | 1413 |
if_match='if match', |
1391 | 1414 |
if_none_match='if non match', |
1392 | 1415 |
if_modified_since='some date here', |
1393 |
if_unmodified_since='some date here', |
|
1394 |
data_range='10-20') |
|
1416 |
if_unmodified_since='some date here') |
|
1395 | 1417 |
with patch.object( |
1396 |
pithos.PithosClient, 'object_get', |
|
1397 |
return_value=FR()) as get: |
|
1418 |
pithos.PithosClient, 'object_get', return_value=FR()) as get: |
|
1398 | 1419 |
r = self.client.get_object_hashmap(obj) |
1399 | 1420 |
self.assertEqual(r, object_hashmap) |
1400 | 1421 |
self.assertEqual(get.mock_calls[-1], call(obj, **exp_args)) |
... | ... | |
1811 | 1832 |
if not argv[1:] or argv[1] == 'PithosRestClient': |
1812 | 1833 |
not_found = False |
1813 | 1834 |
runTestCase(PithosRestClient, 'PithosRest Client', argv[2:]) |
1835 |
if not argv[1:] or argv[1] == 'PithosMethods': |
|
1836 |
not_found = False |
|
1837 |
runTestCase(PithosRestClient, 'Pithos Methods', argv[2:]) |
|
1814 | 1838 |
if not_found: |
1815 | 1839 |
print('TestCase %s not found' % argv[1]) |
Also available in: Unified diff