Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
instance = MockHttpProvider.return_value
instance.send.return_value = response
instance = MockAuthProvider.return_value
instance.authenticate.return_value = "blah"
instance.authenticate_request.return_value = None
http_provider = onedrivesdk.HttpProvider()
auth_provider = onedrivesdk.AuthProvider()
client = onedrivesdk.OneDriveClient("onedriveurl/", http_provider, auth_provider)
items = client.drives["me"].items["root"].children.request().get()
assert items._next_page_link is not None
request = onedrivesdk.ChildrenCollectionRequest.get_next_page_request(items, client)
assert isinstance(request, ChildrenCollectionRequest)
assert isinstance(request.get(), ChildrenCollectionPage)
try:
remote_item_page = item_request_call(self.repo, self.item_request.children.get)
all_remote_items = remote_item_page
while True:
# HACK: ChildrenCollectionPage is not guaranteed to have
# the _next_page_link attribute and
# ChildrenCollectionPage.get_next_page_request doesn't
# implement the check correctly
if not hasattr(remote_item_page, '_next_page_link'):
break
logging.debug('Paging for more items: %s', self.rel_path)
remote_item_page = item_request_call(
self.repo,
ChildrenCollectionRequest.get_next_page_request(
remote_item_page,
self.repo.authenticator.client).get)
all_remote_items = itertools.chain(
all_remote_items, remote_item_page)
except onedrivesdk.error.OneDriveError as e:
logging.error('Encountered API Error: %s. Skip directory "%s".', e, self.rel_path)
return
for remote_item in all_remote_items:
remote_is_folder = remote_item.folder is not None
all_local_items.discard(remote_item.name) # Remove remote item from untouched list.
if not self.repo.path_filter.should_ignore(self.rel_path + '/' + remote_item.name, remote_is_folder):
self._handle_remote_item(remote_item, all_local_items, all_records)
else:
logging.debug('Ignored remote path "%s/%s".', self.rel_path, remote_item.name)