Esempio n. 1
0
    def test_move_object_to_other_account(self):
        account = self.account
        container = get_random_name()
        obj = get_random_name()
        self.b.put_container(account, account, container)

        other_account = get_random_name()
        self.b.put_container(other_account, other_account, container)

        folder = 'shared'
        self.create_folder(other_account, other_account, container, folder,
                           permissions={'write': [account]})

        data = self._upload_object(account, account, container, obj)

        other_obj = '/'.join([folder, obj])
        self.b.move_object(account,
                           account, container, obj,
                           other_account, container, other_obj,
                           'application/octet-stream',
                           domain='pithos')

        self.expected_issue_commission_calls += [
            call.issue_one_commission(
                holder=other_account,
                provisions={(other_account, 'pithos.diskspace'): len(data)},
                name='/'.join([other_account, container, other_obj])),
            call.issue_one_commission(
                holder=account,
                provisions={(account, 'pithos.diskspace'): -len(data)},
                name='/'.join([account, container, obj]))]
Esempio n. 2
0
 def _upload_object(self, user, account, container, obj, data=None,
                    length=None, type_='application/octet-stream',
                    permissions=None):
     data = self.upload_object(user, account, container, obj, data, length,
                               type_, permissions)
     _, container_node = self.b._lookup_container(account, container)
     project = self.b._get_project(container_node)
     if len(data) != 0:
         self.expected_issue_commission_calls += [
             call.issue_one_commission(
                 holder=account,
                 provisions={(project, 'pithos.diskspace'): len(data)},
                 name='/'.join([account, container, obj]))]
     return data
Esempio n. 3
0
    def test_move_obj_to_other_project(self):
        account = self.account
        container = get_random_name()
        obj = get_random_name()
        self.b.put_container(account, account, container)
        data = self._upload_object(account, account, container, obj)

        other_container = get_random_name()
        project = unicode(uuidlib.uuid4())
        self.b.put_container(account, account, other_container,
                             policy={'project': project})
        self.b.move_object(account, account, container, obj,
                           account, other_container, obj,
                           'application/octet-stream',
                           domain='pithos')
        self.expected_issue_commission_calls += [
            call.issue_one_commission(
                holder=account,
                provisions={(project, 'pithos.diskspace'): len(data)},
                name='/'.join([account, other_container, obj])),
            call.issue_one_commission(
                holder=account,
                provisions={(account, 'pithos.diskspace'): -len(data)},
                name='/'.join([account, container, obj]))]
Esempio n. 4
0
    def test_copy_object(self):
        account = self.account
        container = get_random_name()
        obj = get_random_name()
        self.b.put_container(account, account, container)
        data = self._upload_object(account, account, container, obj)

        other_obj = get_random_name()
        self.b.copy_object(account, account, container, obj,
                           account, container, other_obj,
                           'application/octet-stream',
                           domain='pithos')
        self.expected_issue_commission_calls += [call.issue_one_commission(
            holder=account,
            provisions={(account, 'pithos.diskspace'): len(data)},
            name='/'.join([account, container, other_obj]))]