-
-
Notifications
You must be signed in to change notification settings - Fork 278
Add support for all streams #1408
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
Open
theViz343
wants to merge
18
commits into
zulip:main
Choose a base branch
from
theViz343:add-support-for-all-streams
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
80e3344
model/api_types: Add data structures to support non-subscribed streams.
theViz343 82ed222
model: Add stream id accessor methods.
theViz343 d1a8eb7
refactor: model: Use get_stream_name instead of stream_dict.
theViz343 b51eae4
refactor: model/views: Use get_stream_subscribers instead of stream_d…
theViz343 80e0d5a
refactor: model: Use stream_date_created (get/set)ter methods.
theViz343 b6ab397
refactor: model: Use is_stream_web_public instead of stream_dict.
theViz343 55d8560
refactor: model: Use stream_message_retention_days (get/set)ter methods.
theViz343 023ea38
refactor: model: Use is_stream_invite_only instead of stream_dict.
theViz343 6282150
refactor: model/views: Use get_stream_post_policy accessor method.
theViz343 71d5bd0
refactor: model/views: Use is_stream_announcement_only accessor method.
theViz343 6a67577
refactor: model/views: Use is_stream_history_public_to_subscribers me…
theViz343 f451244
refactor: model/views: Use get_stream_weekly_traffic method.
theViz343 8d6e057
refactor: model/views: Use get_stream_rendered_description method.
theViz343 5e5bd20
model: Add get_all_subscription_ids accessor method.
theViz343 dee7e2b
refactor: model: Use get_subscription_color instead of stream_dict.
theViz343 e39bbe3
refactor: model/views: Use get_subscription_email instead of stream_d…
theViz343 5ca5ee6
refactor: model: Improve stream_dict typing.
theViz343 308fa13
refactor: model: Rename stream_dict to _subscribed_streams.
theViz343 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
from pytest_mock import MockerFixture | ||
from urwid import Widget | ||
|
||
from zulipterminal.api_types import Message, MessageType | ||
from zulipterminal.api_types import Message, MessageType, Stream, Subscription | ||
from zulipterminal.config.keys import ( | ||
ZT_TO_URWID_CMD_MAPPING, | ||
keys_for_command, | ||
|
@@ -207,7 +207,7 @@ def logged_on_user() -> Dict[str, Any]: | |
|
||
|
||
@pytest.fixture | ||
def general_stream() -> Dict[str, Any]: | ||
def general_stream() -> Subscription: | ||
return { | ||
"name": "Some general stream", | ||
"date_created": 1472091253, | ||
|
@@ -216,24 +216,29 @@ def general_stream() -> Dict[str, Any]: | |
"pin_to_top": False, | ||
"stream_id": 1000, | ||
"is_muted": False, | ||
"is_web_public": False, | ||
"audible_notifications": False, | ||
"description": "General Stream", | ||
"rendered_description": "General Stream", | ||
"is_old_stream": True, | ||
"desktop_notifications": False, | ||
"stream_weekly_traffic": 0, | ||
"push_notifications": False, | ||
"email_address": "[email protected]", | ||
"message_retention_days": 10, | ||
"subscribers": [1001, 11, 12], | ||
"history_public_to_subscribers": True, | ||
"is_announcement_only": False, | ||
"stream_post_policy": 0, | ||
"first_message_id": 1, | ||
"email_notifications": False, | ||
"wildcard_mentions_notify": False, | ||
} | ||
|
||
|
||
# This is a private stream; | ||
# only description/stream_id/invite_only/name/color vary from above | ||
@pytest.fixture | ||
def secret_stream() -> Dict[str, Any]: | ||
def secret_stream() -> Subscription: | ||
return { | ||
"description": "Some private stream", | ||
"stream_id": 99, | ||
|
@@ -245,20 +250,25 @@ def secret_stream() -> Dict[str, Any]: | |
"rendered_description": "Some private stream", | ||
"color": "#ccc", # Color in '#xxx' format | ||
"is_muted": False, | ||
"is_web_public": False, | ||
"audible_notifications": False, | ||
"is_old_stream": True, | ||
"desktop_notifications": False, | ||
"stream_weekly_traffic": 0, | ||
"message_retention_days": -1, | ||
"push_notifications": False, | ||
"subscribers": [1001, 11], | ||
"history_public_to_subscribers": False, | ||
"is_announcement_only": False, | ||
"stream_post_policy": 0, | ||
"first_message_id": 1, | ||
"email_notifications": False, | ||
"wildcard_mentions_notify": False, | ||
} | ||
|
||
|
||
# Like public stream but with is_web_public=True | ||
@pytest.fixture | ||
def web_public_stream() -> Dict[str, Any]: | ||
def web_public_stream() -> Subscription: | ||
return { | ||
"description": "Some web public stream", | ||
"stream_id": 999, | ||
|
@@ -271,23 +281,42 @@ def web_public_stream() -> Dict[str, Any]: | |
"color": "#ddd", # Color in '#xxx' format | ||
"is_muted": False, | ||
"audible_notifications": False, | ||
"is_old_stream": True, | ||
"desktop_notifications": False, | ||
"stream_weekly_traffic": 0, | ||
"message_retention_days": -1, | ||
"push_notifications": False, | ||
"subscribers": [1001, 11], | ||
"history_public_to_subscribers": False, | ||
"is_web_public": True, | ||
"is_announcement_only": False, | ||
"stream_post_policy": 0, | ||
"first_message_id": 1, | ||
"email_notifications": False, | ||
"wildcard_mentions_notify": False, | ||
} | ||
|
||
|
||
@pytest.fixture | ||
def get_stream_from_id_fixture( | ||
stream_id: int, | ||
_subscribed_streams: Dict[int, Subscription], | ||
unsubscribed_streams_fixture: Dict[int, Subscription], | ||
never_subscribed_streams_fixture: Dict[int, Stream], | ||
) -> Union[Subscription, Stream]: | ||
if stream_id in _subscribed_streams: | ||
return _subscribed_streams[stream_id] | ||
elif stream_id in unsubscribed_streams_fixture: | ||
return unsubscribed_streams_fixture[stream_id] | ||
else: | ||
return never_subscribed_streams_fixture[stream_id] | ||
|
||
|
||
@pytest.fixture | ||
def streams_fixture( | ||
general_stream: Dict[str, Any], | ||
secret_stream: Dict[str, Any], | ||
web_public_stream: Dict[str, Any], | ||
) -> List[Dict[str, Any]]: | ||
general_stream: Subscription, | ||
secret_stream: Subscription, | ||
web_public_stream: Subscription, | ||
) -> List[Subscription]: | ||
streams = [general_stream, secret_stream, web_public_stream] | ||
for i in range(1, 3): | ||
streams.append( | ||
|
@@ -302,14 +331,19 @@ def streams_fixture( | |
"audible_notifications": False, | ||
"description": f"A description of stream {i}", | ||
"rendered_description": f"A description of stream {i}", | ||
"is_old_stream": True, | ||
"desktop_notifications": False, | ||
"stream_weekly_traffic": 0, | ||
"push_notifications": False, | ||
"message_retention_days": i + 30, | ||
"email_address": f"stream{i}@example.com", | ||
"subscribers": [1001, 11, 12], | ||
"history_public_to_subscribers": True, | ||
"is_web_public": False, | ||
"is_announcement_only": False, | ||
"stream_post_policy": 0, | ||
"first_message_id": 1, | ||
"email_notifications": False, | ||
"wildcard_mentions_notify": False, | ||
} | ||
) | ||
return deepcopy(streams) | ||
|
@@ -630,7 +664,7 @@ def mentioned_messages_combination(request: Any) -> Tuple[Set[int], Set[int]]: | |
def initial_data( | ||
logged_on_user: Dict[str, Any], | ||
users_fixture: List[Dict[str, Any]], | ||
streams_fixture: List[Dict[str, Any]], | ||
streams_fixture: List[Dict[str, Subscription]], | ||
realm_emojis: Dict[str, Dict[str, Any]], | ||
) -> Dict[str, Any]: | ||
""" | ||
|
@@ -1189,7 +1223,62 @@ def user_id(logged_on_user: Dict[str, Any]) -> int: | |
|
||
|
||
@pytest.fixture | ||
def stream_dict(streams_fixture: List[Dict[str, Any]]) -> Dict[int, Any]: | ||
def unsubscribed_streams_fixture() -> Dict[int, Subscription]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be easier to compare them if these were added near to the streams_fixture, which is currently much higher in the file :) |
||
unsubscribed_streams: Dict[int, Subscription] = {} | ||
for i in range(3, 5): | ||
unsubscribed_streams[i] = { | ||
"name": f"Stream {i}", | ||
"date_created": 1472047124 + i, | ||
"invite_only": False, | ||
"color": "#b0a5fd", | ||
"pin_to_top": False, | ||
"stream_id": i, | ||
"is_muted": False, | ||
"audible_notifications": False, | ||
"description": f"A description of stream {i}", | ||
"rendered_description": f"A description of stream {i}", | ||
"desktop_notifications": False, | ||
"stream_weekly_traffic": 0, | ||
"push_notifications": False, | ||
"message_retention_days": i + 30, | ||
"email_address": f"stream{i}@example.com", | ||
"email_notifications": False, | ||
"wildcard_mentions_notify": False, | ||
"subscribers": [1001, 11, 12], | ||
"history_public_to_subscribers": True, | ||
"is_announcement_only": True, | ||
"stream_post_policy": 0, | ||
"is_web_public": True, | ||
"first_message_id": None, | ||
} | ||
return deepcopy(unsubscribed_streams) | ||
|
||
|
||
@pytest.fixture | ||
def never_subscribed_streams_fixture() -> Dict[int, Stream]: | ||
never_subscribed_streams: Dict[int, Stream] = {} | ||
for i in range(5, 7): | ||
never_subscribed_streams[i] = { | ||
"name": f"Stream {i}", | ||
"date_created": 1472047124 + i, | ||
"invite_only": False, | ||
"stream_id": i, | ||
"description": f"A description of stream {i}", | ||
"rendered_description": f"A description of stream {i}", | ||
"stream_weekly_traffic": 0, | ||
"message_retention_days": i + 30, | ||
"subscribers": [1001, 11, 12], | ||
"history_public_to_subscribers": True, | ||
"is_announcement_only": True, | ||
"stream_post_policy": 0, | ||
"is_web_public": True, | ||
"first_message_id": None, | ||
} | ||
return deepcopy(never_subscribed_streams) | ||
|
||
|
||
@pytest.fixture | ||
def _subscribed_streams(streams_fixture: List[Subscription]) -> Dict[int, Subscription]: | ||
return {stream["stream_id"]: stream for stream in streams_fixture} | ||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does this belong in the next commit?
I also have two concerns about this fixture, if we keep it: