def test_move_to_existing_path(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 = get_random_name() self._upload_object(account, account, container, other, length=len(data) + 1) # upload more data self.b.move_object(account, account, container, obj, account, container, other, 'application/octet-stream', domain='pithos') self.expected_issue_commission_calls += [call.issue_one_commissions( holder=account, provisions={(account, 'pithos.diskspace'): -1 - len(data)}, name='/'.join([account, container, other]))] data = self._upload_object(account, account, container, obj) other = get_random_name() self._upload_object(account, account, container, other, length=len(data) - 1) # upload less data self.b.move_object(account, account, container, obj, account, container, other, 'application/octet-stream', domain='pithos') self.expected_issue_commission_calls += [call.issue_one_commissions( holder=account, provisions={(account, 'pithos.diskspace'): 1 - len(data)}, name='/'.join([account, container, other]))]
def test_copy_dir_to_other_account(self): account = self.account container = 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 = get_random_name() self.create_folder(account, account, container, folder, permissions={'read': [other_account]}) obj1 = '/'.join([folder, get_random_name()]) data1 = self._upload_object(account, account, container, obj1) obj2 = '/'.join([folder, get_random_name()]) data2 = self._upload_object(account, account, container, obj2) self.b.copy_object(other_account, account, container, folder, other_account, container, folder, 'application/directory', domain='pithos', delimiter='/') self.expected_issue_commission_calls += [ call.issue_one_commissions( holder=other_account, provisions={(other_account, 'pithos.diskspace'): len(data1)}, name='/'.join([other_account, container, obj1])), call.issue_one_commissions( holder=other_account, provisions={(other_account, 'pithos.diskspace'): len(data2)}, name='/'.join([other_account, container, obj2]))]
def test_move_dir_to_other_project(self): account = self.account container = get_random_name() self.b.put_container(account, account, container) folder = get_random_name() self.create_folder(account, account, container, folder) obj1 = '/'.join([folder, get_random_name()]) data1 = self._upload_object(account, account, container, obj1) obj2 = '/'.join([folder, get_random_name()]) data2 = self._upload_object(account, account, container, obj2) other_container = get_random_name() project = unicode(uuidlib.uuid4()) self.b.put_container(account, account, other_container, policy={'project': project}) other_folder = get_random_name() self.create_folder(account, account, other_container, other_folder) # create object under the new folder # having the same name as an object in the initial folder obj3 = obj1.replace(folder, other_folder, 1) data3 = self._upload_object(account, account, other_container, obj3) obj4 = '/'.join([other_folder, get_random_name()]) self._upload_object(account, account, other_container, obj4) self.b.move_object(account, account, container, folder, account, other_container, other_folder, 'application/directory', domain='pithos', delimiter='/') self.expected_issue_commission_calls += [ call.issue_one_commissions( holder=account, provisions={(project, 'pithos.diskspace'): len(data1) - len(data3)}, name='/'.join([account, other_container, obj3])), call.issue_one_commissions( holder=account, provisions={(account, 'pithos.diskspace'): -len(data1)}, name='/'.join([account, container, obj1])), call.issue_one_commissions( holder=account, provisions={(project, 'pithos.diskspace'): len(data2)}, name='/'.join([account, other_container, obj2.replace(folder, other_folder, 1)])), call.issue_one_commissions( holder=account, provisions={(account, 'pithos.diskspace'): -len(data2)}, name='/'.join([account, container, obj2]))]
def test_move_dir_to_existing_path(self): account = self.account container = get_random_name() self.b.put_container(account, account, container) folder = get_random_name() self.create_folder(account, account, container, folder) obj1 = '/'.join([folder, get_random_name()]) self._upload_object(account, account, container, obj1) obj2 = '/'.join([folder, get_random_name()]) self._upload_object(account, account, container, obj2) other_folder = get_random_name() self.create_folder(account, account, container, other_folder) # create object under the new folder # having the same name as an object in the initial folder obj3 = obj1.replace(folder, other_folder, 1) data3 = self._upload_object(account, account, container, obj3) obj4 = '/'.join([other_folder, get_random_name()]) self._upload_object(account, account, container, obj4) self.b.move_object(account, account, container, folder, account, container, other_folder, 'application/directory', domain='pithos', delimiter='/') self.expected_issue_commission_calls += [ call.issue_one_commissions( holder=account, provisions={(account, 'pithos.diskspace'): - len(data3)}, name='/'.join([account, container, other_folder]))]
def test_delete_object(self): account = self.account container = get_random_name() project = unicode(uuidlib.uuid4()) self.b.put_container(account, account, container, policy={'project': project}) obj = get_random_name() data = self._upload_object(account, account, container, obj) self.b.delete_object(account, account, container, obj) self.expected_issue_commission_calls += [ call.issue_one_commissions( holder=account, provisions={(project, 'pithos.diskspace'): -len(data)}, name='/'.join([account, container, obj]))]
def test_delete_container_contents(self): account = self.account container = get_random_name() project = unicode(uuidlib.uuid4()) self.b.put_container(account, account, container, policy={'project': project}) folder = get_random_name() self.create_folder(account, account, container, folder) obj1 = '/'.join([folder, get_random_name()]) data = self._upload_object(account, account, container, obj1) obj2 = '/'.join([folder, get_random_name()]) data += self._upload_object(account, account, container, obj2) self.b.delete_container(account, account, container, delimiter='/') self.expected_issue_commission_calls += [ call.issue_one_commissions( holder=account, provisions={(project, 'pithos.diskspace'): -len(data)}, name='/'.join([account, container, '']))]