Revision 1e1d6f27 kamaki/clients/livetest/pithos.py

b/kamaki/clients/livetest/pithos.py
174 174
        for format in self.client.DATE_FORMATS:
175 175
            now_formated = self.now_unformated.strftime(format)
176 176
            r1 = self.client.account_head(
177
                if_modified_since=now_formated,
178
                success=(204, 304, 412))
177
                if_modified_since=now_formated, success=(204, 304, 412))
179 178
            sc1 = r1.status_code
180 179
            r2 = self.client.account_head(
181
                if_unmodified_since=now_formated,
182
                success=(204, 304, 412))
180
                if_unmodified_since=now_formated, success=(204, 304, 412))
183 181
            sc2 = r2.status_code
184 182
            self.assertNotEqual(sc1, sc2)
185 183

  
......
217 215
        for format in self.client.DATE_FORMATS:
218 216
            now_formated = self.now_unformated.strftime(format)
219 217
            r1 = self.client.account_get(
220
                if_modified_since=now_formated,
221
                success=(200, 304, 412))
218
                if_modified_since=now_formated, success=(200, 304, 412))
222 219
            sc1 = r1.status_code
223 220
            r2 = self.client.account_get(
224
                if_unmodified_since=now_formated,
225
                success=(200, 304, 412))
221
                if_unmodified_since=now_formated, success=(200, 304, 412))
226 222
            sc2 = r2.status_code
227 223
            self.assertNotEqual(sc1, sc2)
228 224

  
......
258 254
            self.client.set_account_group(grpName, [u1, u3])
259 255
            r = self.client.get_account_group()
260 256
            self.assertEqual(
261
                r['x-account-group-' + grpName],
262
                '%s,%s' % (u1, u3))
257
                r['x-account-group-' + grpName], '%s,%s' % (u1, u3))
263 258
        except:
264 259
            print('\tInvalid user id %s (it is ok, though)' % u3)
265 260
        self.client.del_account_group(grpName)
......
268 263

  
269 264
        mprefix = 'meta' + unicode(self.now)
270 265
        self.client.set_account_meta({
271
            mprefix + '1': 'v1',
272
            mprefix + '2': 'v2'})
266
            mprefix + '1': 'v1', mprefix + '2': 'v2'})
273 267
        r = self.client.get_account_meta()
274 268
        self.assertEqual(r['x-account-meta-' + mprefix + '1'], 'v1')
275 269
        self.assertEqual(r['x-account-meta-' + mprefix + '2'], 'v2')
......
312 306
        for format in self.client.DATE_FORMATS:
313 307
            now_formated = self.now_unformated.strftime(format)
314 308
            r1 = self.client.container_head(
315
                if_modified_since=now_formated,
316
                success=(204, 304, 412))
309
                if_modified_since=now_formated, success=(204, 304, 412))
317 310
            sc1 = r1.status_code
318 311
            r2 = self.client.container_head(
319
                if_unmodified_since=now_formated,
320
                success=(204, 304, 412))
312
                if_unmodified_since=now_formated, success=(204, 304, 412))
321 313
            sc2 = r2.status_code
322 314
            self.assertNotEqual(sc1, sc2)
323 315

  
......
377 369
        for format in self.client.DATE_FORMATS:
378 370
            now_formated = self.now_unformated.strftime(format)
379 371
            r1 = self.client.container_get(
380
                if_modified_since=now_formated,
381
                success=(200, 304, 412))
372
                if_modified_since=now_formated, success=(200, 304, 412))
382 373
            sc1 = r1.status_code
383 374
            r2 = self.client.container_get(
384
                if_unmodified_since=now_formated,
385
                success=(200, 304, 412))
375
                if_unmodified_since=now_formated, success=(200, 304, 412))
386 376
            sc2 = r2.status_code
387 377
            self.assertNotEqual(sc1, sc2)
388 378

  
......
550 540
        self.assertTrue(len(r[0]) > 1)
551 541
        self.client.purge_container()
552 542
        self.assertRaises(
553
            ClientError,
554
            self.client.get_object_versionlist,
555
            'test')
543
            ClientError, self.client.get_object_versionlist, 'test')
556 544

  
557 545
    def _test_0080_recreate_deleted_data(self):
558 546
        self._init_data()
......
576 564
        self.assertEqual(r.status_code, 200)
577 565

  
578 566
        r = self.client.object_head(
579
            obj,
580
            if_etag_not_match=etag,
581
            success=(200, 412, 304))
567
            obj, if_etag_not_match=etag, success=(200, 412, 304))
582 568
        self.assertNotEqual(r.status_code, 200)
583 569

  
584 570
        r = self.client.object_head(
585
            obj,
586
            version=40,
587
            if_etag_match=etag,
588
            success=412)
571
            obj, version=40, if_etag_match=etag, success=412)
589 572
        self.assertEqual(r.status_code, 412)
590 573

  
591 574
        """Check and if(un)modified_since"""
592 575
        for format in self.client.DATE_FORMATS:
593 576
            now_formated = self.now_unformated.strftime(format)
594 577
            r1 = self.client.object_head(
595
                obj,
596
                if_modified_since=now_formated,
597
                success=(200, 304, 412))
578
                obj, if_modified_since=now_formated, success=(200, 304, 412))
598 579
            sc1 = r1.status_code
599 580
            r2 = self.client.object_head(
600
                obj,
601
                if_unmodified_since=now_formated,
602
                success=(200, 304, 412))
581
                obj, if_unmodified_since=now_formated, success=(200, 304, 412))
603 582
            sc2 = r2.status_code
604 583
            self.assertNotEqual(sc1, sc2)
605 584

  
......
626 605

  
627 606
        rangestr = 'bytes=%s-%s' % (osize / 3, osize / 2)
628 607
        r = self.client.object_get(
629
            obj,
630
            data_range=rangestr,
631
            success=(200, 206))
608
            obj, data_range=rangestr, success=(200, 206))
632 609
        partsize = int(r.headers['content-length'])
633 610
        self.assertTrue(0 < partsize and partsize <= 1 + osize / 3)
634 611

  
635 612
        rangestr = 'bytes=%s-%s' % (osize / 3, osize / 2)
636 613
        r = self.client.object_get(
637
            obj,
638
            data_range=rangestr,
639
            if_range=True,
640
            success=(200, 206))
614
            obj, data_range=rangestr, if_range=True, success=(200, 206))
641 615
        partsize = int(r.headers['content-length'])
642 616
        self.assertTrue(0 < partsize and partsize <= 1 + osize / 3)
643 617

  
......
651 625
        for format in self.client.DATE_FORMATS:
652 626
            now_formated = self.now_unformated.strftime(format)
653 627
            r1 = self.client.object_get(
654
                obj,
655
                if_modified_since=now_formated,
656
                success=(200, 304, 412))
628
                obj, if_modified_since=now_formated, success=(200, 304, 412))
657 629
            sc1 = r1.status_code
658 630
            r2 = self.client.object_get(
659
                obj,
660
                if_unmodified_since=now_formated,
661
                success=(200, 304, 412))
631
                obj, if_unmodified_since=now_formated, success=(200, 304, 412))
662 632
            sc2 = r2.status_code
663 633
            self.assertNotEqual(sc1, sc2)
664 634

  
......
669 639
        src_f = self.create_large_file(f_size)
670 640
        print('\tUploading...')
671 641
        r = self.client.upload_object(
672
            trg_fname, src_f,
673
            container_info_cache=container_info_cache)
642
            trg_fname, src_f, container_info_cache=container_info_cache)
674 643
        print('\tDownloading...')
675 644
        self.files.append(NamedTemporaryFile())
676 645
        dnl_f = self.files[-1]
......
686 655
        for pos in (0, f_size / 2, f_size - 256):
687 656
            src_f.seek(pos)
688 657
            tmp_s = self.client.download_to_string(
689
                trg_fname,
690
                range_str='%s-%s' % (pos, (pos + 128)))
658
                trg_fname, range_str='%s-%s' % (pos, (pos + 128)))
691 659
            self.assertEqual(tmp_s, src_f.read(len(tmp_s)))
692 660
        print('\tUploading KiBs as strings...')
693 661
        trg_fname = 'fromString_%s' % self.now
......
704 672
        src_f = self.create_boring_file(42)
705 673
        print('\tUploading boring file...')
706 674
        self.client.upload_object(
707
            trg_fname, src_f,
708
            container_info_cache=container_info_cache)
675
            trg_fname, src_f, container_info_cache=container_info_cache)
709 676
        print('\tDownloading boring file...')
710 677
        self.files.append(NamedTemporaryFile())
711 678
        dnl_f = self.files[-1]
......
783 750
        """Check content_type and content_length"""
784 751
        tmpdir = 'dir' + unicode(self.now)
785 752
        r = self.client.object_put(
786
            tmpdir,
787
            content_type='application/directory',
788
            content_length=0)
753
            tmpdir, content_type='application/directory', content_length=0)
789 754

  
790 755
        r = self.client.get_object_info(tmpdir)
791 756
        self.assertEqual(r['content-type'], 'application/directory')
......
1162 1127

  
1163 1128
        """Check permissions"""
1164 1129
        self.client.set_object_sharing(
1165
            obj,
1166
            read_permission=['u4', 'u5'],
1167
            write_permission=['u4'])
1130
            obj, read_permission=['u4', 'u5'], write_permission=['u4'])
1168 1131
        r = self.client.get_object_sharing(obj)
1169 1132
        self.assertTrue('read' in r)
1170 1133
        self.assertTrue('u5' in r['read'])
......
1249 1212
                content_type='application/octet-stream')
1250 1213

  
1251 1214
        self.client.create_object_by_manifestation(
1252
            mobj,
1253
            content_type='application/octet-stream')
1215
            mobj, content_type='application/octet-stream')
1254 1216

  
1255 1217
        r = self.client.object_post(
1256
            mobj,
1257
            manifest='%s/%s' % (self.client.container, mobj))
1218
            mobj, manifest='%s/%s' % (self.client.container, mobj))
1258 1219

  
1259 1220
        r = self.client.object_get(mobj)
1260 1221
        self.assertEqual(r.text, txt)

Also available in: Unified diff