Revision 24ff0a35 kamaki/clients/tests/pithos.py
b/kamaki/clients/tests/pithos.py | ||
---|---|---|
91 | 91 |
|
92 | 92 |
def create_remote_object(self, container, obj): |
93 | 93 |
self.client.container = container |
94 |
self.client.object_put(obj, |
|
94 |
self.client.object_put( |
|
95 |
obj, |
|
95 | 96 |
content_type='application/octet-stream', |
96 | 97 |
data='file %s that lives in %s' % (obj, container), |
97 | 98 |
metadata={'incontainer': container}) |
... | ... | |
149 | 150 |
"""Check if(un)modified_since""" |
150 | 151 |
for format in self.client.DATE_FORMATS: |
151 | 152 |
now_formated = self.now_unformated.strftime(format) |
152 |
r1 = self.client.account_head(if_modified_since=now_formated, |
|
153 |
r1 = self.client.account_head( |
|
154 |
if_modified_since=now_formated, |
|
153 | 155 |
success=(204, 304, 412)) |
154 | 156 |
sc1 = r1.status_code |
155 | 157 |
r1.release() |
156 |
r2 = self.client.account_head(if_unmodified_since=now_formated, |
|
158 |
r2 = self.client.account_head( |
|
159 |
if_unmodified_since=now_formated, |
|
157 | 160 |
success=(204, 304, 412)) |
158 | 161 |
sc2 = r2.status_code |
159 | 162 |
r2.release() |
... | ... | |
178 | 181 |
temp_c2 = r.json[2]['name'] |
179 | 182 |
|
180 | 183 |
r = self.client.account_get(limit=2, marker='c2_') |
181 |
conames = [container['name'] for container in r.json \
|
|
182 |
if container['name'].lower().startswith('c2_')]
|
|
184 |
conames = [container['name'] for container in r.json if (
|
|
185 |
container['name'].lower().startswith('c2_'))]
|
|
183 | 186 |
self.assertTrue(temp_c0 in conames) |
184 | 187 |
self.assertFalse(temp_c2 in conames) |
185 | 188 |
|
... | ... | |
192 | 195 |
"""Check if(un)modified_since""" |
193 | 196 |
for format in self.client.DATE_FORMATS: |
194 | 197 |
now_formated = self.now_unformated.strftime(format) |
195 |
r1 = self.client.account_get(if_modified_since=now_formated, |
|
198 |
r1 = self.client.account_get( |
|
199 |
if_modified_since=now_formated, |
|
196 | 200 |
success=(200, 304, 412)) |
197 | 201 |
sc1 = r1.status_code |
198 | 202 |
r1.release() |
199 |
r2 = self.client.account_get(if_unmodified_since=now_formated, |
|
203 |
r2 = self.client.account_get( |
|
204 |
if_unmodified_since=now_formated, |
|
200 | 205 |
success=(200, 304, 412)) |
201 | 206 |
sc2 = r2.status_code |
202 | 207 |
r2.release() |
... | ... | |
228 | 233 |
self.assertTrue('x-account-group-' + grpName not in r) |
229 | 234 |
|
230 | 235 |
mprefix = 'meta' + unicode(self.now) |
231 |
self.client.set_account_meta({mprefix + '1': 'v1', |
|
236 |
self.client.set_account_meta({ |
|
237 |
mprefix + '1': 'v1', |
|
232 | 238 |
mprefix + '2': 'v2'}) |
233 | 239 |
r = self.client.get_account_meta() |
234 | 240 |
self.assertEqual(r['x-account-meta-' + mprefix + '1'], 'v1') |
... | ... | |
271 | 277 |
"""Check and if(un)modified_since""" |
272 | 278 |
for format in self.client.DATE_FORMATS: |
273 | 279 |
now_formated = self.now_unformated.strftime(format) |
274 |
r1 = self.client.container_head(if_modified_since=now_formated, |
|
280 |
r1 = self.client.container_head( |
|
281 |
if_modified_since=now_formated, |
|
275 | 282 |
success=(204, 304, 412)) |
276 | 283 |
sc1 = r1.status_code |
277 | 284 |
r1.release() |
278 |
r2 = self.client.container_head(if_unmodified_since=now_formated, |
|
285 |
r2 = self.client.container_head( |
|
286 |
if_unmodified_since=now_formated, |
|
279 | 287 |
success=(204, 304, 412)) |
280 | 288 |
sc2 = r2.status_code |
281 | 289 |
r2.release() |
... | ... | |
336 | 344 |
"""Check and if un/modified_since""" |
337 | 345 |
for format in self.client.DATE_FORMATS: |
338 | 346 |
now_formated = self.now_unformated.strftime(format) |
339 |
r1 = self.client.container_get(if_modified_since=now_formated, |
|
347 |
r1 = self.client.container_get( |
|
348 |
if_modified_since=now_formated, |
|
340 | 349 |
success=(200, 304, 412)) |
341 | 350 |
sc1 = r1.status_code |
342 | 351 |
r1.release() |
343 |
r2 = self.client.container_get(if_unmodified_since=now_formated, |
|
352 |
r2 = self.client.container_get( |
|
353 |
if_unmodified_since=now_formated, |
|
344 | 354 |
success=(200, 304, 412)) |
345 | 355 |
sc2 = r2.status_code |
346 | 356 |
r2.release() |
... | ... | |
465 | 475 |
#TODO |
466 | 476 |
|
467 | 477 |
"""Check update=False""" |
468 |
r = self.client.object_post('test', |
|
478 |
r = self.client.object_post( |
|
479 |
'test', |
|
469 | 480 |
update=False, |
470 | 481 |
metadata={'newmeta': 'newval'}) |
471 | 482 |
|
... | ... | |
506 | 517 |
self.assertTrue(len(r) > 0) |
507 | 518 |
self.assertTrue(len(r[0]) > 1) |
508 | 519 |
self.client.purge_container() |
509 |
self.assertRaises(ClientError, |
|
520 |
self.assertRaises( |
|
521 |
ClientError, |
|
510 | 522 |
self.client.get_object_versionlist, |
511 | 523 |
'test') |
512 | 524 |
|
... | ... | |
531 | 543 |
r = self.client.object_head(obj, if_etag_match=etag) |
532 | 544 |
self.assertEqual(r.status_code, 200) |
533 | 545 |
|
534 |
r = self.client.object_head(obj, |
|
546 |
r = self.client.object_head( |
|
547 |
obj, |
|
535 | 548 |
if_etag_not_match=etag, |
536 | 549 |
success=(200, 412, 304)) |
537 | 550 |
self.assertNotEqual(r.status_code, 200) |
538 | 551 |
|
539 |
r = self.client.object_head(obj, |
|
552 |
r = self.client.object_head( |
|
553 |
obj, |
|
540 | 554 |
version=40, |
541 | 555 |
if_etag_match=etag, |
542 | 556 |
success=412) |
... | ... | |
545 | 559 |
"""Check and if(un)modified_since""" |
546 | 560 |
for format in self.client.DATE_FORMATS: |
547 | 561 |
now_formated = self.now_unformated.strftime(format) |
548 |
r1 = self.client.object_head(obj, if_modified_since=now_formated, |
|
562 |
r1 = self.client.object_head( |
|
563 |
obj, |
|
564 |
if_modified_since=now_formated, |
|
549 | 565 |
success=(200, 304, 412)) |
550 | 566 |
sc1 = r1.status_code |
551 | 567 |
r1.release() |
552 |
r2 = self.client.object_head(obj, if_unmodified_since=now_formated, |
|
568 |
r2 = self.client.object_head( |
|
569 |
obj, |
|
570 |
if_unmodified_since=now_formated, |
|
553 | 571 |
success=(200, 304, 412)) |
554 | 572 |
sc2 = r2.status_code |
555 | 573 |
r2.release() |
... | ... | |
570 | 588 |
etag = r.headers['etag'] |
571 | 589 |
|
572 | 590 |
r = self.client.object_get(obj, hashmap=True) |
573 |
self.assertTrue('hashes' in r.json\ |
|
574 |
and 'block_hash' in r.json\ |
|
575 |
and 'block_size' in r.json\ |
|
576 |
and 'bytes' in r.json) |
|
591 |
for term in ('hashes', 'block_hash', 'block_hash', 'bytes'): |
|
592 |
self.assertTrue(term in r.json) |
|
577 | 593 |
|
578 | 594 |
r = self.client.object_get(obj, format='xml', hashmap=True) |
579 | 595 |
self.assertEqual(len(r.text.split('hash>')), 3) |
580 | 596 |
|
581 | 597 |
rangestr = 'bytes=%s-%s' % (osize / 3, osize / 2) |
582 |
r = self.client.object_get(obj, |
|
598 |
r = self.client.object_get( |
|
599 |
obj, |
|
583 | 600 |
data_range=rangestr, |
584 | 601 |
success=(200, 206)) |
585 | 602 |
partsize = int(r.headers['content-length']) |
586 | 603 |
self.assertTrue(0 < partsize and partsize <= 1 + osize / 3) |
587 | 604 |
|
588 | 605 |
rangestr = 'bytes=%s-%s' % (osize / 3, osize / 2) |
589 |
r = self.client.object_get(obj, |
|
606 |
r = self.client.object_get( |
|
607 |
obj, |
|
590 | 608 |
data_range=rangestr, |
591 | 609 |
if_range=True, |
592 | 610 |
success=(200, 206)) |
... | ... | |
602 | 620 |
"""Check and if(un)modified_since""" |
603 | 621 |
for format in self.client.DATE_FORMATS: |
604 | 622 |
now_formated = self.now_unformated.strftime(format) |
605 |
r1 = self.client.object_get(obj, if_modified_since=now_formated, |
|
623 |
r1 = self.client.object_get( |
|
624 |
obj, |
|
625 |
if_modified_since=now_formated, |
|
606 | 626 |
success=(200, 304, 412)) |
607 | 627 |
sc1 = r1.status_code |
608 | 628 |
r1.release() |
609 |
r2 = self.client.object_get(obj, |
|
629 |
r2 = self.client.object_get( |
|
630 |
obj, |
|
610 | 631 |
if_unmodified_since=now_formated, |
611 | 632 |
success=(200, 304, 412)) |
612 | 633 |
sc2 = r2.status_code |
... | ... | |
646 | 667 |
r = self.client.object_put(obj, |
647 | 668 |
data='a', |
648 | 669 |
content_type='application/octer-stream', |
649 |
permissions={
|
|
650 |
'read': ['accX:groupA', 'u1', 'u2'],
|
|
651 |
'write': ['u2', 'u3']},
|
|
652 |
metadata={'key1': 'val1', 'key2': 'val2'},
|
|
670 |
permissions=dict(
|
|
671 |
read=['accX:groupA', 'u1', 'u2'],
|
|
672 |
write=['u2', 'u3']),
|
|
673 |
metadata=dict(key1='val1', key2='val2'),
|
|
653 | 674 |
content_encoding='UTF-8', |
654 | 675 |
content_disposition='attachment; filename="fname.ext"') |
655 | 676 |
self.assertEqual(r.status_code, 201) |
... | ... | |
672 | 693 |
self.assertEqual(r['x-object-meta-key2'], 'val2') |
673 | 694 |
|
674 | 695 |
"""Check public and if_etag_match""" |
675 |
r = self.client.object_put(obj, if_etag_match=etag, data='b', |
|
676 |
content_type='application/octet-stream', public=True) |
|
696 |
r = self.client.object_put( |
|
697 |
obj, |
|
698 |
if_etag_match=etag, |
|
699 |
data='b', |
|
700 |
content_type='application/octet-stream', |
|
701 |
public=True) |
|
677 | 702 |
|
678 | 703 |
r = self.client.object_get(obj) |
679 | 704 |
self.assertTrue('x-object-public' in r.headers) |
... | ... | |
682 | 707 |
self.assertEqual(r.text, 'b') |
683 | 708 |
|
684 | 709 |
"""Check if_etag_not_match""" |
685 |
r = self.client.object_put(obj, if_etag_not_match=etag, data='c', |
|
686 |
content_type='application/octet-stream', success=(201, 412)) |
|
710 |
r = self.client.object_put( |
|
711 |
obj, |
|
712 |
if_etag_not_match=etag, |
|
713 |
data='c', |
|
714 |
content_type='application/octet-stream', |
|
715 |
success=(201, 412)) |
|
687 | 716 |
self.assertEqual(r.status_code, 412) |
688 | 717 |
|
689 | 718 |
"""Check content_type and content_length""" |
690 | 719 |
tmpdir = 'dir' + unicode(self.now) |
691 |
r = self.client.object_put(tmpdir, |
|
720 |
r = self.client.object_put( |
|
721 |
tmpdir, |
|
692 | 722 |
content_type='application/directory', |
693 | 723 |
content_length=0) |
694 | 724 |
|
... | ... | |
696 | 726 |
self.assertEqual(r['content-type'], 'application/directory') |
697 | 727 |
|
698 | 728 |
"""Check copy_from, content_encoding""" |
699 |
r = self.client.object_put('%s/%s' % (tmpdir, obj), |
|
729 |
r = self.client.object_put( |
|
730 |
'%s/%s' % (tmpdir, obj), |
|
700 | 731 |
format=None, |
701 | 732 |
copy_from='/%s/%s' % (self.client.container, obj), |
702 | 733 |
content_encoding='application/octet-stream', |
703 | 734 |
source_account=self.client.account, |
704 |
content_length=0, success=201) |
|
735 |
content_length=0, |
|
736 |
success=201) |
|
705 | 737 |
self.assertEqual(r.status_code, 201) |
706 | 738 |
|
707 | 739 |
"""Test copy_object for cross-conctainer copy""" |
708 |
self.client.copy_object(src_container=self.c2, |
|
740 |
self.client.copy_object( |
|
741 |
src_container=self.c2, |
|
709 | 742 |
src_object='%s/%s' % (tmpdir, obj), |
710 | 743 |
dst_container=self.c1, |
711 | 744 |
dst_object=obj) |
... | ... | |
718 | 751 |
"""Check cross-container copy_from, content_encoding""" |
719 | 752 |
self.client.container = self.c1 |
720 | 753 |
fromstr = '/%s/%s/%s' % (self.c2, tmpdir, obj) |
721 |
r = self.client.object_put(obj, |
|
754 |
r = self.client.object_put( |
|
755 |
obj, |
|
722 | 756 |
format=None, |
723 | 757 |
copy_from=fromstr, |
724 | 758 |
content_encoding='application/octet-stream', |
725 | 759 |
source_account=self.client.account, |
726 |
content_length=0, success=201) |
|
760 |
content_length=0, |
|
761 |
success=201) |
|
727 | 762 |
|
728 | 763 |
self.assertEqual(r.status_code, 201) |
729 | 764 |
r = self.client.get_object_info(obj) |
... | ... | |
732 | 767 |
"""Check source_account""" |
733 | 768 |
self.client.container = self.c2 |
734 | 769 |
fromstr = '/%s/%s' % (self.c1, obj) |
735 |
r = self.client.object_put(obj + 'v2', |
|
770 |
r = self.client.object_put( |
|
771 |
'%sv2' % obj, |
|
736 | 772 |
format=None, |
737 | 773 |
move_from=fromstr, |
738 | 774 |
content_encoding='application/octet-stream', |
... | ... | |
745 | 781 |
self.client.container = self.c1 |
746 | 782 |
r1 = self.client.get_object_info(obj) |
747 | 783 |
self.client.container = self.c2 |
748 |
self.client.move_object(src_container=self.c1, |
|
784 |
self.client.move_object( |
|
785 |
src_container=self.c1, |
|
749 | 786 |
src_object=obj, |
750 | 787 |
dst_container=self.c2, |
751 | 788 |
dst_object=obj + 'v0') |
... | ... | |
753 | 790 |
self.assertEqual(r1['x-object-hash'], r0['x-object-hash']) |
754 | 791 |
|
755 | 792 |
"""Check move_from""" |
756 |
r = self.client.object_put(obj + 'v1', |
|
793 |
r = self.client.object_put( |
|
794 |
'%sv1' % obj, |
|
757 | 795 |
format=None, |
758 | 796 |
move_from='/%s/%s' % (self.c2, obj), |
759 | 797 |
source_version=vers2, |
... | ... | |
765 | 803 |
txt = '' |
766 | 804 |
for i in range(10): |
767 | 805 |
txt += '%s' % i |
768 |
r = self.client.object_put('%s/%s' % (mobj, i), |
|
806 |
r = self.client.object_put( |
|
807 |
'%s/%s' % (mobj, i), |
|
769 | 808 |
data='%s' % i, |
770 | 809 |
content_length=1, |
771 | 810 |
success=201, |
772 | 811 |
content_type='application/octet-stream', |
773 | 812 |
content_encoding='application/octet-stream') |
774 | 813 |
|
775 |
r = self.client.object_put(mobj, |
|
814 |
r = self.client.object_put( |
|
815 |
mobj, |
|
776 | 816 |
content_length=0, |
777 | 817 |
content_type='application/octet-stream', |
778 | 818 |
manifest='%s/%s' % (self.client.container, mobj)) |
... | ... | |
801 | 841 |
r = self.client.object_put(obj + 'orig', |
802 | 842 |
content_type='application/octet-stream', |
803 | 843 |
data=data, |
804 |
metadata={'mkey1': 'mval1', 'mkey2': 'mval2'},
|
|
805 |
permissions={
|
|
806 |
'read': ['accX:groupA', 'u1', 'u2'],
|
|
807 |
'write': ['u2', 'u3']},
|
|
844 |
metadata=dict(mkey1='mval1', mkey2='mval2'),
|
|
845 |
permissions=dict(
|
|
846 |
read=['accX:groupA', 'u1', 'u2'],
|
|
847 |
write=['u2', 'u3']),
|
|
808 | 848 |
content_disposition='attachment; filename="fname.ext"') |
809 | 849 |
|
810 |
r = self.client.object_copy(obj + 'orig', |
|
850 |
r = self.client.object_copy( |
|
851 |
'%sorig' % obj, |
|
811 | 852 |
destination='/%s/%s' % (self.client.container, obj), |
812 | 853 |
ignore_content_type=False, content_type='application/json', |
813 | 854 |
metadata={'mkey2': 'mval2a', 'mkey3': 'mval3'}, |
... | ... | |
830 | 871 |
self.assertTrue('accx:groupb' in r['write']) |
831 | 872 |
|
832 | 873 |
"""Check destination account""" |
833 |
r = self.client.object_copy(obj, |
|
874 |
r = self.client.object_copy( |
|
875 |
obj, |
|
834 | 876 |
destination='/%s/%s' % (self.c1, obj), |
835 | 877 |
content_encoding='utf8', |
836 | 878 |
content_type='application/json', |
... | ... | |
840 | 882 |
|
841 | 883 |
"""Check destination being another container |
842 | 884 |
and also content_type and content encoding""" |
843 |
r = self.client.object_copy(obj, |
|
885 |
r = self.client.object_copy( |
|
886 |
obj, |
|
844 | 887 |
destination='/%s/%s' % (self.c1, obj), |
845 | 888 |
content_encoding='utf8', |
846 | 889 |
content_type='application/json') |
847 | 890 |
self.assertEqual(r.status_code, 201) |
848 |
self.assertEqual(r.headers['content-type'], |
|
891 |
self.assertEqual( |
|
892 |
r.headers['content-type'], |
|
849 | 893 |
'application/json; charset=UTF-8') |
850 | 894 |
|
851 | 895 |
"""Check ignore_content_type and content_type""" |
... | ... | |
854 | 898 |
ctype = r.headers['content-type'] |
855 | 899 |
self.assertEqual(ctype, 'application/json') |
856 | 900 |
|
857 |
r = self.client.object_copy(obj + 'orig', |
|
901 |
r = self.client.object_copy( |
|
902 |
'%sorig' % obj, |
|
858 | 903 |
destination='/%s/%s0' % (self.client.container, obj), |
859 | 904 |
ignore_content_type=True, |
860 | 905 |
content_type='application/json') |
... | ... | |
862 | 907 |
self.assertNotEqual(r.headers['content-type'], 'application/json') |
863 | 908 |
|
864 | 909 |
"""Check if_etag_(not_)match""" |
865 |
r = self.client.object_copy(obj, |
|
910 |
r = self.client.object_copy( |
|
911 |
obj, |
|
866 | 912 |
destination='/%s/%s1' % (self.client.container, obj), |
867 | 913 |
if_etag_match=etag) |
868 | 914 |
self.assertEqual(r.status_code, 201) |
869 | 915 |
|
870 |
r = self.client.object_copy(obj, |
|
916 |
r = self.client.object_copy( |
|
917 |
obj, |
|
871 | 918 |
destination='/%s/%s2' % (self.client.container, obj), |
872 | 919 |
if_etag_not_match='lalala') |
873 | 920 |
self.assertEqual(r.status_code, 201) |
874 | 921 |
vers2 = r.headers['x-object-version'] |
875 | 922 |
|
876 | 923 |
"""Check source_version, public and format """ |
877 |
r = self.client.object_copy(obj + '2', |
|
924 |
r = self.client.object_copy( |
|
925 |
'%s2' % obj, |
|
878 | 926 |
destination='/%s/%s3' % (self.client.container, obj), |
879 | 927 |
source_version=vers2, |
880 | 928 |
format='xml', |
... | ... | |
894 | 942 |
obj = 'test2' |
895 | 943 |
|
896 | 944 |
data = '{"key1": "val1", "key2": "val2"}' |
897 |
r = self.client.object_put(obj + 'orig', |
|
945 |
r = self.client.object_put( |
|
946 |
'%sorig' % obj, |
|
898 | 947 |
content_type='application/octet-stream', |
899 | 948 |
data=data, |
900 |
metadata={'mkey1': 'mval1', 'mkey2': 'mval2'}, |
|
901 |
permissions={'read': ['accX:groupA', 'u1', 'u2'], |
|
902 |
'write': ['u2', 'u3']}) |
|
949 |
metadata=dict(mkey1='mval1', mkey2='mval2'), |
|
950 |
permissions=dict( |
|
951 |
read=['accX:groupA', 'u1', 'u2'], |
|
952 |
write=['u2', 'u3'])) |
|
903 | 953 |
|
904 |
r = self.client.object_move(obj + 'orig', |
|
954 |
r = self.client.object_move( |
|
955 |
'%sorig' % obj, |
|
905 | 956 |
destination='/%s/%s' % (self.client.container, obj), |
906 | 957 |
ignore_content_type=False, |
907 | 958 |
content_type='application/json', |
908 |
metadata={'mkey2': 'mval2a', 'mkey3': 'mval3'},
|
|
909 |
permissions={'write': ['u5', 'accX:groupB']})
|
|
959 |
metadata=dict(mkey2='mval2a', mkey3='mval3'),
|
|
960 |
permissions=dict(write=['u5', 'accX:groupB']))
|
|
910 | 961 |
self.assertEqual(r.status_code, 201) |
911 | 962 |
|
912 | 963 |
"""Check Metadata""" |
... | ... | |
922 | 973 |
self.assertTrue('accx:groupb' in r['write']) |
923 | 974 |
|
924 | 975 |
"""Check destination account""" |
925 |
r = self.client.object_move(obj, |
|
976 |
r = self.client.object_move( |
|
977 |
obj, |
|
926 | 978 |
destination='/%s/%s' % (self.c1, obj), |
927 | 979 |
content_encoding='utf8', |
928 | 980 |
content_type='application/json', |
... | ... | |
932 | 984 |
|
933 | 985 |
"""Check destination being another container and also |
934 | 986 |
content_type, content_disposition and content encoding""" |
935 |
r = self.client.object_move(obj, |
|
987 |
r = self.client.object_move( |
|
988 |
obj, |
|
936 | 989 |
destination='/%s/%s' % (self.c1, obj), |
937 | 990 |
content_encoding='utf8', |
938 | 991 |
content_type='application/json', |
939 | 992 |
content_disposition='attachment; filename="fname.ext"') |
940 | 993 |
self.assertEqual(r.status_code, 201) |
941 |
self.assertEqual(r.headers['content-type'], |
|
994 |
self.assertEqual( |
|
995 |
r.headers['content-type'], |
|
942 | 996 |
'application/json; charset=UTF-8') |
943 | 997 |
self.client.container = self.c1 |
944 | 998 |
r = self.client.get_object_info(obj) |
945 |
self.assertTrue('content-disposition' in r\
|
|
946 |
and 'fname.ext' in r['content-disposition'])
|
|
999 |
self.assertTrue('content-disposition' in r)
|
|
1000 |
self.assertTrue('fname.ext' in r['content-disposition'])
|
|
947 | 1001 |
etag = r['etag'] |
948 | 1002 |
ctype = r['content-type'] |
949 | 1003 |
self.assertEqual(ctype, 'application/json') |
950 | 1004 |
|
951 | 1005 |
"""Check ignore_content_type and content_type""" |
952 |
r = self.client.object_move(obj, |
|
1006 |
r = self.client.object_move( |
|
1007 |
obj, |
|
953 | 1008 |
destination='/%s/%s' % (self.c2, obj), |
954 | 1009 |
ignore_content_type=True, |
955 | 1010 |
content_type='application/json') |
... | ... | |
958 | 1013 |
|
959 | 1014 |
"""Check if_etag_(not_)match""" |
960 | 1015 |
self.client.container = self.c2 |
961 |
r = self.client.object_move(obj, |
|
1016 |
r = self.client.object_move( |
|
1017 |
obj, |
|
962 | 1018 |
destination='/%s/%s0' % (self.client.container, obj), |
963 | 1019 |
if_etag_match=etag) |
964 | 1020 |
self.assertEqual(r.status_code, 201) |
965 | 1021 |
|
966 |
r = self.client.object_move(obj + '0', |
|
1022 |
r = self.client.object_move( |
|
1023 |
'%s0' % obj, |
|
967 | 1024 |
destination='/%s/%s1' % (self.client.container, obj), |
968 | 1025 |
if_etag_not_match='lalala') |
969 | 1026 |
self.assertEqual(r.status_code, 201) |
970 | 1027 |
|
971 | 1028 |
"""Check public and format """ |
972 |
r = self.client.object_move(obj + '1', |
|
1029 |
r = self.client.object_move( |
|
1030 |
'%s1' % obj, |
|
973 | 1031 |
destination='/%s/%s2' % (self.client.container, obj), |
974 |
format='xml', public=True) |
|
1032 |
format='xml', |
|
1033 |
public=True) |
|
975 | 1034 |
self.assertEqual(r.status_code, 201) |
976 | 1035 |
self.assertTrue(r.headers['content-type'].index('xml') > 0) |
977 | 1036 |
|
... | ... | |
988 | 1047 |
"""create a filesystem file""" |
989 | 1048 |
self.files.append(NamedTemporaryFile()) |
990 | 1049 |
newf = self.files[-1] |
991 |
newf.writelines(['ello!\n', |
|
1050 |
newf.writelines([ |
|
1051 |
'ello!\n', |
|
992 | 1052 |
'This is a test line\n', |
993 | 1053 |
'inside a test file\n']) |
994 | 1054 |
"""create a file on container""" |
995 |
r = self.client.object_put(obj, |
|
1055 |
r = self.client.object_put( |
|
1056 |
obj, |
|
996 | 1057 |
content_type='application/octet-stream', |
997 | 1058 |
data='H', |
998 |
metadata={'mkey1': 'mval1', 'mkey2': 'mval2'}, |
|
999 |
permissions={'read': ['accX:groupA', 'u1', 'u2'], |
|
1000 |
'write': ['u2', 'u3']}) |
|
1059 |
metadata=dict(mkey1='mval1', mkey2='mval2'), |
|
1060 |
permissions=dict( |
|
1061 |
read=['accX:groupA', 'u1', 'u2'], |
|
1062 |
write=['u2', 'u3'])) |
|
1001 | 1063 |
|
1002 | 1064 |
"""Append tests update, content_range, content_type, content_length""" |
1003 | 1065 |
newf.seek(0) |
... | ... | |
1030 | 1092 |
self.assertFalse('x-object-meta-mkey1' in r) |
1031 | 1093 |
|
1032 | 1094 |
"""Check permissions""" |
1033 |
self.client.set_object_sharing(obj, |
|
1034 |
read_permition=['u4', 'u5'], write_permition=['u4']) |
|
1095 |
self.client.set_object_sharing( |
|
1096 |
obj, |
|
1097 |
read_permition=['u4', 'u5'], |
|
1098 |
write_permition=['u4']) |
|
1035 | 1099 |
r = self.client.get_object_sharing(obj) |
1036 | 1100 |
self.assertTrue('read' in r) |
1037 | 1101 |
self.assertTrue('u5' in r['read']) |
... | ... | |
1052 | 1116 |
"""Check if_etag_(not)match""" |
1053 | 1117 |
etag = r['etag'] |
1054 | 1118 |
""" |
1055 |
r = self.client.object_post(obj, |
|
1119 |
r = self.client.object_post( |
|
1120 |
obj, |
|
1056 | 1121 |
update=True, |
1057 | 1122 |
public=True, |
1058 | 1123 |
if_etag_not_match=etag, |
... | ... | |
1060 | 1125 |
self.assertEqual(r.status_code, 412) |
1061 | 1126 |
""" |
1062 | 1127 |
|
1063 |
r = self.client.object_post(obj, update=True, public=True, |
|
1064 |
if_etag_match=etag, content_encoding='application/json') |
|
1128 |
r = self.client.object_post( |
|
1129 |
obj, |
|
1130 |
update=True, |
|
1131 |
public=True, |
|
1132 |
if_etag_match=etag, |
|
1133 |
content_encoding='application/json') |
|
1065 | 1134 |
|
1066 | 1135 |
r = self.client.get_object_info(obj) |
1067 | 1136 |
helloVersion = r['x-object-version'] |
... | ... | |
1069 | 1138 |
self.assertEqual(r['content-encoding'], 'application/json') |
1070 | 1139 |
|
1071 | 1140 |
"""Check source_version and source_account and content_disposition""" |
1072 |
r = self.client.object_post(obj, |
|
1141 |
r = self.client.object_post( |
|
1142 |
obj, |
|
1073 | 1143 |
update=True, |
1074 | 1144 |
content_type='application/octet-srteam', |
1075 | 1145 |
content_length=5, |
... | ... | |
1081 | 1151 |
success=(403, 202, 204)) |
1082 | 1152 |
self.assertEqual(r.status_code, 403) |
1083 | 1153 |
|
1084 |
r = self.client.object_post(obj, |
|
1154 |
r = self.client.object_post( |
|
1155 |
obj, |
|
1085 | 1156 |
update=True, |
1086 | 1157 |
content_type='application/octet-srteam', |
1087 | 1158 |
content_length=5, |
... | ... | |
1094 | 1165 |
|
1095 | 1166 |
r = self.client.object_get(obj) |
1096 | 1167 |
self.assertEqual(r.text, 'eello!') |
1097 |
self.assertTrue('content-disposition' in r.headers\
|
|
1098 |
and 'fname.ext' in r.headers['content-disposition'])
|
|
1168 |
self.assertTrue('content-disposition' in r.headers)
|
|
1169 |
self.assertTrue('fname.ext' in r.headers['content-disposition'])
|
|
1099 | 1170 |
|
1100 | 1171 |
"""Check manifest""" |
1101 | 1172 |
mobj = 'manifest.test' |
1102 | 1173 |
txt = '' |
1103 | 1174 |
for i in range(10): |
1104 | 1175 |
txt += '%s' % i |
1105 |
r = self.client.object_put('%s/%s' % (mobj, i), |
|
1106 |
data='%s' % i, |
|
1107 |
content_length=1, |
|
1108 |
success=201, |
|
1109 |
content_encoding='application/octet-stream', |
|
1110 |
content_type='application/octet-stream') |
|
1176 |
r = self.client.object_put( |
|
1177 |
'%s/%s' % (mobj, i), |
|
1178 |
data='%s' % i, |
|
1179 |
content_length=1, |
|
1180 |
success=201, |
|
1181 |
content_encoding='application/octet-stream', |
|
1182 |
content_type='application/octet-stream') |
|
1111 | 1183 |
|
1112 |
self.client.create_object_by_manifestation(mobj, |
|
1184 |
self.client.create_object_by_manifestation( |
|
1185 |
mobj, |
|
1113 | 1186 |
content_type='application/octet-stream') |
1114 | 1187 |
|
1115 |
r = self.client.object_post(mobj, |
|
1188 |
r = self.client.object_post( |
|
1189 |
mobj, |
|
1116 | 1190 |
manifest='%s/%s' % (self.client.container, mobj)) |
1117 | 1191 |
|
1118 | 1192 |
r = self.client.object_get(mobj) |
... | ... | |
1128 | 1202 |
self.client.container = self.c2 |
1129 | 1203 |
obj = 'test2' |
1130 | 1204 |
"""create a file on container""" |
1131 |
r = self.client.object_put(obj, |
|
1205 |
r = self.client.object_put( |
|
1206 |
obj, |
|
1132 | 1207 |
content_type='application/octet-stream', |
1133 | 1208 |
data='H', |
1134 |
metadata={'mkey1': 'mval1', 'mkey2': 'mval2'}, |
|
1135 |
permissions={'read': ['accX:groupA', 'u1', 'u2'], |
|
1136 |
'write': ['u2', 'u3']}) |
|
1209 |
metadata=dict(mkey1='mval1', mkey2='mval2'), |
|
1210 |
permissions=dict( |
|
1211 |
read=['accX:groupA', 'u1', 'u2'], |
|
1212 |
write=['u2', 'u3'])) |
|
1137 | 1213 |
|
1138 | 1214 |
"""Check with false until""" |
1139 | 1215 |
r = self.client.object_delete(obj, until=1000000) |
Also available in: Unified diff