Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into issue_#1344
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajnus committed Nov 14, 2024
2 parents 7fc7202 + d88adae commit c18670c
Show file tree
Hide file tree
Showing 7 changed files with 710 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/developer-file-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Zulip Terminal uses [Zulip's API](https://zulip.com/api/) to store and retrieve
| | unicode_emojis.py | Unicode emoji data, synchronized semi-regularly with the server source |
| | urwid_types.py | Types from the urwid API, to improve type checking |
| | version.py | Keeps track of the version of the current code |
| | widget.py | Process widgets (submessages) like polls, todo lists, etc. |
| | | |
| zulipterminal/cli | run.py | Marks the entry point into the application |
| | | |
Expand Down
230 changes: 230 additions & 0 deletions tests/model/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def test_register_initial_desired_events(self, mocker, initial_data):
"message",
"update_message",
"reaction",
"submessage",
"subscription",
"typing",
"update_message_flags",
Expand Down Expand Up @@ -2913,6 +2914,235 @@ def test__handle_reaction_event_for_msg_in_index(

model._update_rendered_view.assert_called_once_with(event_message_id)

@pytest.mark.parametrize(
"submessages, event, expected_updated_submessage",
[
case(
[
{
"id": 1,
"message_id": 1958326,
"sender_id": 27294,
"msg_type": "widget",
"content": (
'{"widget_type": "todo", "extra_data": '
'{"task_list_title": "Today\'s Work", "tasks": [{"task"'
': "Handle submessages events on ZT", "desc": ""}, {"task":'
' "Play ping pong", "desc": ""}]}}'
),
}
],
{
"type": "submessage",
"msg_type": "widget",
"message_id": 1958326,
"submessage_id": 1,
"sender_id": 27294,
"content": '{"type":"strike","key":"0,canned"}',
"id": 1,
},
[
{
"id": 1,
"message_id": 1958326,
"sender_id": 27294,
"msg_type": "widget",
"content": (
'{"widget_type": "todo", "extra_data": '
'{"task_list_title": "Today\'s Work", "tasks": '
'[{"task": "Handle submessages events on ZT", "desc": ""}, '
'{"task": "Play ping pong", "desc": ""}]}}'
),
},
{
"type": "submessage",
"msg_type": "widget",
"message_id": 1958326,
"submessage_id": 1,
"sender_id": 27294,
"content": '{"type":"strike","key":"0,canned"}',
},
],
id="submessage_strike_event_todo_widget",
),
case(
[
{
"id": 1,
"message_id": 1958326,
"sender_id": 27294,
"msg_type": "widget",
"content": (
'{"widget_type": "todo", "extra_data": '
'{"task_list_title": "Today\'s Work", "tasks": [{"task": '
'"Handle submessages events on ZT", "desc": ""}, {"task": '
'"Play ping pong", "desc": ""}]}}'
),
},
{
"id": 12154,
"message_id": 1958326,
"sender_id": 27294,
"msg_type": "widget",
"content": '{"type":"strike","key":"0,canned"}',
},
],
{
"type": "submessage",
"msg_type": "widget",
"message_id": 1958326,
"submessage_id": 12185,
"sender_id": 27294,
"content": (
'{"type":"new_task","key":2,"task":"Make a coffee",'
'"desc":"","completed":false}'
),
"id": 0,
},
[
{
"id": 1,
"message_id": 1958326,
"sender_id": 27294,
"msg_type": "widget",
"content": (
'{"widget_type": "todo", "extra_data": '
'{"task_list_title": "Today\'s Work", "tasks": [{"task": '
'"Handle submessages events on ZT", "desc": ""}, {"task": '
'"Play ping pong", "desc": ""}]}}'
),
},
{
"id": 12154,
"message_id": 1958326,
"sender_id": 27294,
"msg_type": "widget",
"content": '{"type":"strike","key":"0,canned"}',
},
{
"type": "submessage",
"msg_type": "widget",
"message_id": 1958326,
"submessage_id": 12185,
"sender_id": 27294,
"content": (
'{"type":"new_task","key":2,"task":"Make a coffee",'
'"desc":"","completed":false}'
),
},
],
id="submessage_new_task_event_todo_widget",
),
case(
[
{
"id": 12153,
"message_id": 1958326,
"sender_id": 27294,
"msg_type": "widget",
"content": (
'{"widget_type": "todo", "extra_data": '
'{"task_list_title": "Today\'s Work", "tasks": [{"task": '
'"Handle submessages events on ZT", "desc": ""}, {"task": '
'"Play ping pong", "desc": ""}]}}'
),
},
{
"id": 12154,
"message_id": 1958326,
"sender_id": 27294,
"msg_type": "widget",
"content": '{"type":"strike","key":"0,canned"}',
},
{
"type": "submessage",
"msg_type": "widget",
"message_id": 1958326,
"submessage_id": 12185,
"sender_id": 27294,
"content": (
'{"type":"new_task","key":2,"task":"Make a coffee"'
',"desc":"","completed":false}'
),
"id": 0,
},
],
{
"type": "submessage",
"msg_type": "widget",
"message_id": 1958326,
"submessage_id": 12186,
"sender_id": 27294,
"content": (
'{"type":"new_task_list_title","title":"Today\'s Work '
'[Updated]"}'
),
"id": 11,
},
[
{
"id": 12153,
"message_id": 1958326,
"sender_id": 27294,
"msg_type": "widget",
"content": (
'{"widget_type": "todo", "extra_data": '
'{"task_list_title": "Today\'s Work", "tasks": [{"task": '
'"Handle submessages events on ZT", "desc": ""}, {"task": '
'"Play ping pong", "desc": ""}]}}'
),
},
{
"id": 12154,
"message_id": 1958326,
"sender_id": 27294,
"msg_type": "widget",
"content": '{"type":"strike","key":"0,canned"}',
},
{
"type": "submessage",
"msg_type": "widget",
"message_id": 1958326,
"submessage_id": 12185,
"sender_id": 27294,
"content": (
'{"type":"new_task","key":2,"task":"Make a coffee"'
',"desc":"","completed":false}'
),
"id": 0,
},
{
"type": "submessage",
"msg_type": "widget",
"message_id": 1958326,
"submessage_id": 12186,
"sender_id": 27294,
"content": (
'{"type":"new_task_list_title",'
'"title":"Today\'s Work [Updated]"}'
),
},
],
id="submessage_new_task_list_title_event_todo_widget",
),
],
)
def test__handle_submessage_event(
self,
mocker,
model,
submessages,
event,
expected_updated_submessage,
id=1958326,
):
model.index["messages"][id]["submessages"] = submessages
model._update_rendered_view = mocker.Mock()

model._handle_submessage_event(event)

assert model.index["messages"][id]["submessages"] == expected_updated_submessage

@pytest.fixture(
params=[
("op", 32), # At server feature level 32, event uses standard field
Expand Down
Loading

0 comments on commit c18670c

Please sign in to comment.