-
-
Notifications
You must be signed in to change notification settings - Fork 277
Migrated get_next_unread_pm and tests to model. #1395
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
base: main
Are you sure you want to change the base?
Conversation
Hello @WladRamos, it seems like you have referenced #1335 in your pull request description, but you have not referenced them in your commit message description(s). Referencing an issue in a commit message automatically closes the corresponding issue when the commit is merged, which makes the issue tracker easier to manage. Please run An example of a correctly-formatted commit:
To learn how to write a great commit message, please refer to our guide. |
Update test accordingly, and improve similar test to match.
@WladRamos I just merged a slightly trimmed version of your first commit, and the other parts back to this PR. I'm going to make some notes in a moment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WladRamos Thanks for working on this 👍
Here are the comments for the followup commits.
zulipterminal/model.py
Outdated
@@ -902,6 +903,21 @@ def get_next_unread_topic(self) -> Optional[Tuple[int, str]]: | |||
next_topic = True | |||
return None | |||
|
|||
def get_next_unread_pm(self) -> Optional[int]: | |||
pms = sorted(self.unread_counts["unread_pms"].keys()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should stay unsorted for this commit.
@@ -616,6 +616,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: | |||
recipient_emails=[email], | |||
contextual_message_id=pm, | |||
) | |||
return key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is small, but I split it out from the first commit since it's a distraction from the main refactor.
@@ -933,6 +934,7 @@ def test_keypress_NEXT_UNREAD_PM_no_pm( | |||
|
|||
return_value = mid_col_view.keypress(size, key) | |||
|
|||
assert not mid_col_view.controller.narrow_to_user.called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly this looks reasonable, but unrelated to that first commit (migration).
"unread_pms, last_unread_pm, next_unread_pm", | ||
[ | ||
case( | ||
{(1, "pm"), (2, "pm2")}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that unread_pms are, based on the unread_counts definition, int->int, from sender-id to unread count, so these strings are misleading.
def test_get_next_unread_pm( | ||
self, model, unread_pms, last_unread_pm, next_unread_pm | ||
): | ||
model.unread_counts = {"unread_pms": {stream_pm: 1 for stream_pm in unread_pms}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is stream_pm here?
), | ||
case( | ||
{(1, "pm"), (2, "pm2")}, | ||
(1, "pm"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly in the test refactor here, this is setting model.last_unread_pm to a tuple, which is different.
|
||
unread_pm = model.get_next_unread_pm() | ||
|
||
assert unread_pm == next_unread_pm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this missing an assert?
Hello @zulip/server-refactoring members, this pull request was labeled with the "area: refactoring" label, so you may want to check it out! |
@neiljp Thanks for the feedback, I'll take a look. 👍 |
What does this PR do, and why?
This pull request Migrates get_next_unread_pm & tests to model.
Created this new version to the pull request to make it cleaner by splitting the changes into two commits.
This is a precursor for improving the get_next_unread_pm method.
Fixes #1335
External discussion & connections
topic
How did you test this?
Self-review checklist for each commit