From bdaf8955bafe9f63709cb8dc2697d3950f0321a7 Mon Sep 17 00:00:00 2001 From: vgrem Date: Sun, 26 May 2024 14:58:02 +0300 Subject: [PATCH] #866 fixes --- examples/onedrive/files/upload.py | 4 +++- office365/onedrive/driveitems/driveItem.py | 2 +- tests/onedrive/test_file.py | 9 +++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/onedrive/files/upload.py b/examples/onedrive/files/upload.py index 98180616..39b78871 100644 --- a/examples/onedrive/files/upload.py +++ b/examples/onedrive/files/upload.py @@ -13,7 +13,8 @@ ) client = GraphClient.with_client_secret(test_tenant, test_client_id, test_client_secret) -folder = client.users.get_by_principal_name(test_user_principal_name_alt).drive.root +user_drive = client.users.get_by_principal_name(test_user_principal_name_alt).drive +folder = user_drive.root local_path = "../../data/Financial Sample.xlsx" # local_path = "../../data/countries.json" @@ -21,3 +22,4 @@ with open(local_path, "rb") as f: file = folder.upload_file(f).execute_query() print("File {0} has been uploaded".format(file.web_url)) +result = folder.children.get().execute_query() diff --git a/office365/onedrive/driveitems/driveItem.py b/office365/onedrive/driveitems/driveItem.py index c4ddfd06..efb1d3d0 100644 --- a/office365/onedrive/driveitems/driveItem.py +++ b/office365/onedrive/driveitems/driveItem.py @@ -911,7 +911,7 @@ def subscriptions(self): def set_property(self, name, value, persist_changes=True): super(DriveItem, self).set_property(name, value, persist_changes) if name == "parentReference": - self._resource_path.parent.patch(self.parent_reference.driveId) + pass return self def get_property(self, name, default_value=None): diff --git a/tests/onedrive/test_file.py b/tests/onedrive/test_file.py index ba735a0d..7437c152 100644 --- a/tests/onedrive/test_file.py +++ b/tests/onedrive/test_file.py @@ -42,12 +42,9 @@ def test2_get_folder_permissions(self): def test3_upload_file(self): file_name = "SharePoint User Guide.docx" - path = "{0}/../data/{1}".format(os.path.dirname(__file__), file_name) - with open(path, "rb") as content_file: - file_content = content_file.read() - file_name = os.path.basename(path) - self.__class__.target_file = self.target_drive.root.upload( - file_name, file_content + file_path = "{0}/../data/{1}".format(os.path.dirname(__file__), file_name) + self.__class__.target_file = self.target_drive.root.upload_file( + file_path ).execute_query() self.assertIsNotNone(self.target_file.web_url)