-
-
Notifications
You must be signed in to change notification settings - Fork 238
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
Skip muted_streams/topics in getting next unread topic. #442
Conversation
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.
@amanagr Good catch on noticing this issue 👍
There's good extra work here in addition to the actual fix for this issue, and not all the elements seem necessary (or complete) for that fix. You could build extra things into this PR, but my thought would be to split this PR into up to 3 PRs:
- This fix in behavior (1: add tests for existing method, 2: refactor (maybe?), 3/2: fix behavior using existing muting datastructures directly (as elsewhere), extending existing tests
- Encapsulating muted stream/topic checks, as per the current first commit, but as per my inline comment, incorporating a transition towards the rest of the codebase using that/those methods
- Moving to use a
model_fixture
through the code.
Thoughts?
@@ -75,6 +76,31 @@ def msg_box(mocker, messages_successful_response): | |||
|
|||
# --------------- Model Fixtures ---------------------------------------------- | |||
|
|||
@pytest.fixture | |||
def model_fixture(mocker, initial_data, user_profile): |
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 seems great at first glance as another standardized fixture, but while you use it in the following commit, you could illustrate its broader use and appeal in this commit by refactoring some other tests using this new fixture.
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.
Done!
This can be used to run a Model's functions inside other tests.
Added tests.
Use model fixture to make use of is_muted_stream function.
Added tests.
189e6a0
to
899d116
Compare
Heads up @amanagr, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
@@ -386,6 +386,19 @@ def fetch_all_topics(self, workers: int) -> None: | |||
if not result] | |||
raise ServerConnectionFailure(", ".join(failures)) | |||
|
|||
def is_muted_stream(self, stream_id: int) -> bool: | |||
if stream_id in self.muted_streams: |
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 can be just return stream_id in self.muted_streams
.
Logic originally developed by Aman Agrawal (amanagr) in zulip#442. Updated to take into account: - already-added (slightly different) is_muted[stream|topic] methods - migration of get_next_unread_topic into model (simplifying tests) Also ensure the current behavior is maintained for now by explicitly sorting the unread counts, which previous relied upon the initial and subsequent data being ordered. Tests added. Co-authored by: Aman Agrawal <f2016561@pilani.bits-pilani.ac.in>
Logic originally developed by Aman Agrawal (amanagr) in zulip#442. Updated to take into account: - already-added (slightly different) is_muted[stream|topic] methods - migration of get_next_unread_topic into model (simplifying tests) Also ensure the current behavior is maintained for now by explicitly sorting the unread counts, which previous relied upon the initial and subsequent data being ordered. Tests added. Co-authored by: Aman Agrawal <f2016561@pilani.bits-pilani.ac.in>
Logic originally developed by Aman Agrawal (amanagr) in #442. Updated to take into account: - already-added (slightly different) is_muted[stream|topic] methods - migration of get_next_unread_topic into model (simplifying tests) Also ensure the current behavior is maintained for now by explicitly sorting the unread counts, which previous relied upon the initial and subsequent data being ordered. Tests added. Co-authored by: Aman Agrawal <f2016561@pilani.bits-pilani.ac.in>
Logic originally developed by Aman Agrawal (amanagr) in zulip#442. Updated to take into account: - already-added (slightly different) is_muted[stream|topic] methods - migration of get_next_unread_topic into model (simplifying tests) Also ensure the current behavior is maintained for now by explicitly sorting the unread counts, which previous relied upon the initial and subsequent data being ordered. Tests added. Co-authored by: Aman Agrawal <f2016561@pilani.bits-pilani.ac.in>
This PR skips muted topics/streams with
n
hotkey.