Revision 49886c59

b/kamaki/clients/pithos/rest_api.py
612 612
        return self.put(path, *args, success=success, **kwargs)
613 613

  
614 614
    def object_copy(
615
            self, object, destination,
615
            self, obj, destination,
616 616
            format='json',
617 617
            ignore_content_type=False,
618 618
            if_etag_match=None,
......
699 699
            for key, val in metadata.items():
700 700
                self.set_header('X-Object-Meta-' + key, val)
701 701

  
702
        path = path4url(self.account, self.container, object)
702
        path = path4url(self.account, self.container, obj)
703 703
        success = kwargs.pop('success', 201)
704 704
        return self.copy(path, *args, success=success, **kwargs)
705 705

  
b/kamaki/clients/pithos/test.py
547 547
                success=kwargs.pop('success', 201),
548 548
                **kwargs))
549 549

  
550
    @patch('%s.set_param' % rest_pkg)
551
    @patch('%s.set_header' % rest_pkg)
552
    @patch('%s.copy' % rest_pkg, return_value=FR())
553
    def test_object_copy(self, copy, SH, SP):
554
        dest = 'dest1n4710n'
555
        for pm in product(
556
                ('json', 'f0rm47'),
557
                (False, True),
558
                (None, 'ifmatch'),
559
                (None, 'ifnonematch'),
560
                (None, 'destinationaccount'),
561
                (None, 'content-type'),
562
                (None, 'content-encoding'),
563
                (None, 'content-disp'),
564
                (None, 'source-version'),
565
                (dict(), dict(read=['u1', 'g2'], write=['u1'])),
566
                (False, True),
567
                (dict(), dict(k2='v2', k3='v3')),
568
                ((), ('someval',)),
569
                (dict(), dict(success=400), dict(k='v', v='k'))):
570
            args, kwargs = pm[-2:]
571
            pm = pm[:-2]
572
            self.client.object_copy(obj, dest, *(pm + args), **kwargs)
573
            format, ict = pm[:2]
574
            self.assertEqual(SP.mock_calls[-2:], [
575
                call('format', format, iff=format),
576
                call('ignore_content_type', iff=ict)])
577
            im, inm, da, ct, ce, cd, sv, perms, public, metas = pm[2:]
578
            exp = [call('If-Match', im),
579
                call('If-None-Match', inm),
580
                call('Destination', dest),
581
                call('Destination-Account', da),
582
                call('Content-Type', ct),
583
                call('Content-Encoding', ce),
584
                call('Content-Disposition', cd),
585
                call('X-Source-Version', sv)]
586
            if perms:
587
                perm_str = ''
588
                for ptype, pval in perms.items():
589
                    if pval:
590
                        perm_str += ';' if perm_str else ''
591
                        perm_str += '%s=%s' % (ptype, ','.join(pval))
592
                exp += [call('X-Object-Sharing', perm_str)]
593
            exp += [call('X-Object-Public', public)]
594
            for k, v in metas.items():
595
                exp += [call('X-Object-Meta-%s' % k, v)]
596
            self.assertEqual(SH.mock_calls[- len(exp):], exp)
597
            acc, cont = self.client.account, self.client.container
598
            self.assertEqual(copy.mock_calls[-1], call(
599
                '/%s/%s/%s' % (acc, cont, obj),
600
                *args,
601
                success=kwargs.pop('success', 201),
602
                **kwargs))
603

  
550 604

  
551 605
class Pithos(TestCase):
552 606

  

Also available in: Unified diff