-
-
Notifications
You must be signed in to change notification settings - Fork 278
Add support for all streams minimal #1430
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
8
commits into
zulip:main
Choose a base branch
from
theViz343:add-support-for-all-streams-minimal
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
8 commits
Select commit
Hold shift + click to select a range
5ef8286
api_types: Refactor Subscription TypedDict into Stream and Subscription.
theViz343 1197a6e
api_types: Update Stream and Subscription typeddict fields.
theViz343 fe5e5f7
model/api_types: Add data structures to support non-subscribed streams.
theViz343 50241a6
model: Improve typing of stream_dict.
theViz343 96da20b
model: Add stream and subscription id helper methods.
theViz343 6eeb765
model/boxes/buttons/views: Add stream_name_from_id method to model.
theViz343 c53ee61
model/boxes/messages: Add subscription_color_from_id method to model.
theViz343 d0c1a8d
refactor: Reduce the direct usage of stream dict in tests.
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 |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
CustomProfileField, | ||
Message, | ||
MessageType, | ||
Stream, | ||
Subscription, | ||
) | ||
from zulipterminal.config.keys import ( | ||
ZT_TO_URWID_CMD_MAPPING, | ||
|
@@ -231,7 +233,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, | ||
|
@@ -243,21 +245,25 @@ def general_stream() -> Dict[str, Any]: | |
"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": "general@example.comm", | ||
"message_retention_days": 10, | ||
"subscribers": [1001, 11, 12], | ||
"history_public_to_subscribers": True, | ||
"is_announcement_only": False, | ||
"first_message_id": 1, | ||
"email_notifications": False, | ||
"wildcard_mentions_notify": False, | ||
"is_web_public": 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, | ||
|
@@ -270,19 +276,23 @@ def secret_stream() -> Dict[str, Any]: | |
"color": "#ccc", # 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_announcement_only": False, | ||
"first_message_id": 1, | ||
"email_notifications": False, | ||
"wildcard_mentions_notify": False, | ||
"is_web_public": 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, | ||
|
@@ -295,23 +305,26 @@ 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, | ||
"first_message_id": 1, | ||
"email_notifications": False, | ||
"wildcard_mentions_notify": False, | ||
} | ||
|
||
|
||
@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( | ||
|
@@ -326,19 +339,96 @@ 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_announcement_only": False, | ||
"first_message_id": 1, | ||
"email_notifications": False, | ||
"wildcard_mentions_notify": False, | ||
"is_web_public": False, | ||
} | ||
) | ||
return deepcopy(streams) | ||
|
||
|
||
@pytest.fixture | ||
def unsubscribed_streams_fixture() -> List[Subscription]: | ||
unsubscribed_streams: List[Subscription] = [] | ||
for i in range(3, 5): | ||
unsubscribed_streams.append( | ||
{ | ||
"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() -> List[Stream]: | ||
never_subscribed_streams: List[Stream] = [] | ||
for i in range(5, 7): | ||
never_subscribed_streams.append( | ||
{ | ||
"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 all_stream_ids( | ||
streams_fixture: List[Subscription], | ||
unsubscribed_streams_fixture: List[Subscription], | ||
never_subscribed_streams_fixture: List[Stream], | ||
) -> List[int]: | ||
return [ | ||
stream["stream_id"] | ||
for stream in streams_fixture | ||
+ unsubscribed_streams_fixture | ||
+ never_subscribed_streams_fixture | ||
] | ||
|
||
|
||
@pytest.fixture | ||
def realm_emojis() -> Dict[str, Dict[str, Any]]: | ||
# Omitting source_url, author_id (server version 3.0), | ||
|
@@ -872,7 +962,9 @@ def clean_custom_profile_data_fixture() -> List[CustomProfileData]: | |
def initial_data( | ||
logged_on_user: Dict[str, Any], | ||
users_fixture: List[Dict[str, Any]], | ||
streams_fixture: List[Dict[str, Any]], | ||
streams_fixture: List[Subscription], | ||
unsubscribed_streams_fixture: List[Subscription], | ||
never_subscribed_streams_fixture: List[Stream], | ||
realm_emojis: Dict[str, Dict[str, Any]], | ||
custom_profile_fields_fixture: List[Dict[str, Union[str, int]]], | ||
) -> Dict[str, Any]: | ||
|
@@ -884,24 +976,7 @@ def initial_data( | |
"email": logged_on_user["email"], | ||
"user_id": logged_on_user["user_id"], | ||
"realm_name": "Test Organization Name", | ||
"unsubscribed": [ | ||
{ | ||
"audible_notifications": False, | ||
"description": "announce", | ||
"stream_id": 7, | ||
"is_old_stream": True, | ||
"desktop_notifications": False, | ||
"pin_to_top": False, | ||
"stream_weekly_traffic": 0, | ||
"invite_only": False, | ||
"name": "announce", | ||
"push_notifications": False, | ||
"email_address": "", | ||
"color": "#bfd56f", | ||
"is_muted": False, | ||
"history_public_to_subscribers": True, | ||
} | ||
], | ||
"unsubscribed": unsubscribed_streams_fixture, | ||
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. Minor: I'd mention these changes to the fixtures in the commit text, even though we don't use them until now. |
||
"result": "success", | ||
"queue_id": "1522420755:786", | ||
"realm_users": users_fixture, | ||
|
@@ -950,24 +1025,7 @@ def initial_data( | |
"subscriptions": streams_fixture, | ||
"msg": "", | ||
"max_message_id": 552761, | ||
"never_subscribed": [ | ||
{ | ||
"invite_only": False, | ||
"description": "Announcements from the Zulip GCI Mentors", | ||
"stream_id": 87, | ||
"name": "GCI announce", | ||
"is_old_stream": True, | ||
"stream_weekly_traffic": 0, | ||
}, | ||
{ | ||
"invite_only": False, | ||
"description": "General discussion", | ||
"stream_id": 74, | ||
"name": "GCI general", | ||
"is_old_stream": True, | ||
"stream_weekly_traffic": 0, | ||
}, | ||
], | ||
"never_subscribed": never_subscribed_streams_fixture, | ||
"unread_msgs": { | ||
"pms": [ | ||
{"sender_id": 1, "unread_message_ids": [1, 2]}, | ||
|
@@ -1433,10 +1491,30 @@ 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 stream_dict(streams_fixture: List[Subscription]) -> Dict[int, Subscription]: | ||
return {stream["stream_id"]: stream for stream in streams_fixture} | ||
|
||
|
||
@pytest.fixture | ||
def unsubscribed_streams( | ||
unsubscribed_streams_fixture: List[Subscription], | ||
) -> Dict[int, Subscription]: | ||
return { | ||
unsubscribed_stream["stream_id"]: unsubscribed_stream | ||
for unsubscribed_stream in unsubscribed_streams_fixture | ||
} | ||
|
||
|
||
@pytest.fixture | ||
def never_subscribed_streams( | ||
never_subscribed_streams_fixture: List[Stream], | ||
) -> Dict[int, Stream]: | ||
return { | ||
never_subscribed_stream["stream_id"]: never_subscribed_stream | ||
for never_subscribed_stream in never_subscribed_streams_fixture | ||
} | ||
|
||
|
||
@pytest.fixture( | ||
params=[ | ||
{ | ||
|
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.
Uh oh!
There was an error while loading. Please reload this page.