Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Disable cycling while editing a PM #1280

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
31 changes: 31 additions & 0 deletions tests/ui_tools/test_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1731,6 +1731,37 @@ def test__setup_common_private_compose(self, mocker: MockerFixture) -> None:
)
assert write_box.focus_position == 1

@pytest.mark.parametrize(
"recipient_user_ids, expected_recipient_emails, expected_recipient_info",
[
(
[11, 12],
["person1@example.com", "person2@example.com"],
"Human 1 <person1@example.com>, Human 2 <person2@example.com>",
),
([11], ["person1@example.com"], "Human 1 <person1@example.com>"),
([], [], ""),
],
)
def test_update_recipients_from_user_ids(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're testing these elements, it could be useful to include how the other internal function is called for completeness (_set_regular_and_typing_recipient_user_ids).

self,
recipient_user_ids: List[int],
expected_recipient_emails: List[str],
expected_recipient_info: str,
user_dict: List[Dict[str, Any]],
user_id_email_dict: Dict[int, str],
) -> None:
write_box = WriteBox(self.view)
write_box.model.user_id_email_dict = user_id_email_dict
write_box.model.user_dict = user_dict

write_box.recipient_info = write_box.update_recipients_from_user_ids(
recipient_user_ids
)

assert write_box.recipient_emails == expected_recipient_emails
assert write_box.recipient_info == expected_recipient_info
Comment on lines +1822 to +1827
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this isn't too likely to break anything, the assignment to write_box.recipient_info is related to the current implementation of the function that uses this new function (currently private_box_view, if we make that change in the earlier commit). This test should only care about what the function should achieve internally, including what it returns. The return value can be set to a local name in this test function - it doesn't need to be write_box.recipient_info.

This can be one of the challenges of writing tests for helper functions.


@pytest.mark.parametrize("key", keys_for_command("MARKDOWN_HELP"))
def test_keypress_MARKDOWN_HELP(
self, write_box: WriteBox, key: str, widget_size: Callable[[Widget], urwid_Size]
Expand Down