Skip to content

Commit

Permalink
feat(Messages): Change message editing method to update() (#241)
Browse files Browse the repository at this point in the history
Reopening and updating for @zhenyamorozov. Replaces #222 

Tested locally and passing
  • Loading branch information
adamweeks authored Aug 27, 2024
2 parents e417de1 + 4656bcb commit 470225f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/webexpythonsdk/api/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ def delete(self, messageId):
# API request
self._session.delete(API_ENDPOINT + "/" + messageId)

def edit(self, messageId=None, roomId=None, text=None, markdown=None):
"""Edit a message.
def update(self, messageId=None, roomId=None, text=None, markdown=None):
"""Update (edit) a message.
Args:
messageId(str): The ID of the message to be edit.
Expand Down Expand Up @@ -391,3 +391,6 @@ def edit(self, messageId=None, roomId=None, text=None, markdown=None):

# Return a message object created from the response JSON data
return self._object_factory(OBJECT_TYPE, json_data)

# Add edit() as an alias to the update() method for backward compatibility
edit = update
8 changes: 6 additions & 2 deletions tests/api/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,20 @@ def test_get_message_by_id(api, group_room_text_message):
message = api.messages.get(group_room_text_message.id)
assert is_valid_message(message)


def test_delete_message(api, group_room, send_group_room_message):
text = create_string("Message")
message = api.messages.create(group_room.id, text=text)
assert is_valid_message(message)
api.messages.delete(message.id)


def test_edit_message(api, group_room):
text = create_string("Edit this Message")
message = api.messages.create(group_room.id, text=text)
text = create_string("Message Edited")
assert text == api.messages.edit(message.id, group_room.id, text).text

def test_update_message(api, group_room):
text = create_string("Update this Message")
message = api.messages.create(group_room.id, text=text)
text = create_string("Message Updated")
assert text == api.messages.edit(message.id, group_room.id, text).text

0 comments on commit 470225f

Please sign in to comment.