From 377b4290b1c333268a384bbeab9bbee4be169fa3 Mon Sep 17 00:00:00 2001 From: vgrem Date: Sun, 14 Apr 2024 18:43:05 +0300 Subject: [PATCH] 2.5.8 release --- .../sharepoint/userprofile/get_properties.py | 13 ++++++++++ .../sharepoint/userprofiles/people_manager.py | 6 ++--- setup.py | 2 +- tests/outlook/test_messages.py | 24 ++++++++++--------- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/examples/sharepoint/userprofile/get_properties.py b/examples/sharepoint/userprofile/get_properties.py index e69de29bb..c0d50c8ac 100644 --- a/examples/sharepoint/userprofile/get_properties.py +++ b/examples/sharepoint/userprofile/get_properties.py @@ -0,0 +1,13 @@ +""" + Gets user properties for the specified user +""" +from pprint import pprint + +from office365.sharepoint.client_context import ClientContext +from tests import test_client_credentials, test_site_url, test_user_principal_name + +client = ClientContext(test_site_url).with_credentials(test_client_credentials) +user = client.site.root_web.site_users.get_by_email(test_user_principal_name) + +result = client.people_manager.get_properties_for(user).execute_query() +pprint(result.user_profile_properties) diff --git a/office365/sharepoint/userprofiles/people_manager.py b/office365/sharepoint/userprofiles/people_manager.py index af0d7c390..cd7163fde 100644 --- a/office365/sharepoint/userprofiles/people_manager.py +++ b/office365/sharepoint/userprofiles/people_manager.py @@ -165,10 +165,10 @@ def _user_resolved(account_name): _ensure_user(user_or_name, _user_resolved) return return_type - def get_properties_for(self, user_or_name): + def get_properties_for(self, account): """ Gets user properties for the specified user. - :param str or User user_or_name: Specifies the User object or its login name. + :param str or User account: Specifies the User object or its login name. """ return_type = PersonProperties(self.context) @@ -180,7 +180,7 @@ def _get_properties_for_inner(account_name): ) self.context.add_query(qry) - _ensure_user(user_or_name, _get_properties_for_inner) + _ensure_user(account, _get_properties_for_inner) return return_type def get_default_document_library( diff --git a/setup.py b/setup.py index d6e54ed6a..2a5735e29 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name="Office365-REST-Python-Client", - version="2.5.7", + version="2.5.8", author="Vadim Gremyachev", author_email="vvgrem@gmail.com", maintainer="Konrad GÄ…dek, Domenico Di Nicola", diff --git a/tests/outlook/test_messages.py b/tests/outlook/test_messages.py index c8ac751eb..38987d205 100644 --- a/tests/outlook/test_messages.py +++ b/tests/outlook/test_messages.py @@ -17,13 +17,6 @@ def test2_create_draft_message(self): self.assertIsNotNone(draft_message.id) self.__class__.target_message = draft_message - def test3_send_message(self): - message = self.__class__.target_message - message.to_recipients.add(Recipient.from_email(test_user_principal_name)) - message.to_recipients.add(Recipient.from_email(test_user_principal_name_alt)) - message.body = "The new cafeteria is open." - message.update().send().execute_query() - # def test4_create_reply(self): # message = self.__class__.target_message.create_reply().execute_query() # self.assertIsNotNone(message.resource_path) @@ -31,21 +24,21 @@ def test3_send_message(self): # def test4_forward_message(self): # self.__class__.target_message.forward([test_user_principal_name_alt]).execute_query() - def test_5_get_my_messages(self): + def test5_get_my_messages(self): messages = self.client.me.messages.top(1).get().execute_query() self.assertLessEqual(1, len(messages)) self.assertIsNotNone(messages[0].resource_path) - def test_6_update_message(self): + def test6_update_message(self): message_to_update = self.__class__.target_message message_to_update.body = "The new cafeteria is close." message_to_update.update().execute_query() - def test_7_delete_message(self): + def test7_delete_message(self): message_to_delete = self.__class__.target_message message_to_delete.delete_object().execute_query() - def test_8_create_draft_message_with_attachments(self): + def test8_create_draft_message_with_attachments(self): content = base64.b64encode( io.BytesIO(b"This is some file content").read() ).decode() @@ -63,3 +56,12 @@ def test_8_create_draft_message_with_attachments(self): == 2 ) draft.delete_object().execute_query() + + def test9_send_message(self): + message = self.client.me.messages.add( + subject="Meet for lunch?", body="The new cafeteria is open." + ) + message.to_recipients.add(Recipient.from_email(test_user_principal_name)) + message.to_recipients.add(Recipient.from_email(test_user_principal_name_alt)) + message.body = "The new cafeteria is open." + message.update().send().execute_query()