Skip to content

Commit

Permalink
test_messages: Add and modify test for message labels.
Browse files Browse the repository at this point in the history
Tests the conditions for moved and edited label along wth
UI differences.
Fixes #1253
  • Loading branch information
Subhasish-Behera committed Apr 14, 2023
1 parent e74353b commit dff8de8
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions tests/ui_tools/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,18 +1082,52 @@ def test_main_view_compact_output(
assert len(view_components) == 1
assert isinstance(view_components[0], Padding)

def test_main_view_generates_EDITED_label(
self, mocker, messages_successful_response
@pytest.mark.parametrize(
[
"message_edited",
"message_moved",
"expected_left_padding",
"expected_label_text",
],
[
case(True, False, 7, "EDITED", id="message_indexed_to_edited_messages"),
case(False, True, 6, "MOVED", id="message_indexed_to_moved_messages"),
case(
False,
False,
0,
"EDITED",
id="message_neither_index_to_edited_messages_or_moved_messages",
),
],
)
def test_main_view_generates_EDITED_or_MOVED_label(
self,
mocker,
messages_successful_response,
message_edited,
message_moved,
expected_left_padding,
expected_label_text,
):
messages = messages_successful_response["messages"]
for message in messages:
self.model.index["edited_messages"].add(message["id"])
msg_id = message["id"]
message_index = {
"edited_messages": {msg_id} if message_edited else set(),
"moved_messages": {msg_id} if message_moved else set(),
}
self.model.index = dict(
self.model.index,
edited_messages=message_index["edited_messages"],
moved_messages=message_index["moved_messages"],
)
msg_box = MessageBox(message, self.model, message)
view_components = msg_box.main_view()

label = view_components[0].original_widget.contents[0]
assert label[0].text == "EDITED"
assert label[1][1] == 7
assert label[0].text == expected_label_text
assert label[1][1] == expected_left_padding

@pytest.mark.parametrize(
"to_vary_in_last_message, update_required",
Expand Down

0 comments on commit dff8de8

Please sign in to comment.