11
11
CustomProfileField ,
12
12
Message ,
13
13
MessageType ,
14
+ Stream ,
15
+ Subscription ,
14
16
)
15
17
from zulipterminal .config .keys import (
16
18
ZT_TO_URWID_CMD_MAPPING ,
@@ -339,6 +341,66 @@ def streams_fixture(
339
341
return deepcopy (streams )
340
342
341
343
344
+ @pytest .fixture
345
+ def unsubscribed_streams_fixture () -> List [Subscription ]:
346
+ unsubscribed_streams : List [Subscription ] = []
347
+ for i in range (3 , 5 ):
348
+ unsubscribed_streams .append (
349
+ {
350
+ "name" : f"Stream { i } " ,
351
+ "date_created" : 1472047124 + i ,
352
+ "invite_only" : False ,
353
+ "color" : "#b0a5fd" ,
354
+ "pin_to_top" : False ,
355
+ "stream_id" : i ,
356
+ "is_muted" : False ,
357
+ "audible_notifications" : False ,
358
+ "description" : f"A description of stream { i } " ,
359
+ "rendered_description" : f"A description of stream { i } " ,
360
+ "desktop_notifications" : False ,
361
+ "stream_weekly_traffic" : 0 ,
362
+ "push_notifications" : False ,
363
+ "message_retention_days" : i + 30 ,
364
+ "email_address" : f"stream{ i } @example.com" ,
365
+ "email_notifications" : False ,
366
+ "wildcard_mentions_notify" : False ,
367
+ "subscribers" : [1001 , 11 , 12 ],
368
+ "history_public_to_subscribers" : True ,
369
+ "is_announcement_only" : True ,
370
+ "stream_post_policy" : 0 ,
371
+ "is_web_public" : True ,
372
+ "first_message_id" : None ,
373
+ "role" : 1 ,
374
+ }
375
+ )
376
+ return deepcopy (unsubscribed_streams )
377
+
378
+
379
+ @pytest .fixture
380
+ def never_subscribed_streams_fixture () -> List [Stream ]:
381
+ never_subscribed_streams : List [Stream ] = []
382
+ for i in range (5 , 7 ):
383
+ never_subscribed_streams .append (
384
+ {
385
+ "name" : f"Stream { i } " ,
386
+ "date_created" : 1472047124 + i ,
387
+ "invite_only" : False ,
388
+ "stream_id" : i ,
389
+ "description" : f"A description of stream { i } " ,
390
+ "rendered_description" : f"A description of stream { i } " ,
391
+ "stream_weekly_traffic" : 0 ,
392
+ "message_retention_days" : i + 30 ,
393
+ "subscribers" : [1001 , 11 , 12 ],
394
+ "history_public_to_subscribers" : True ,
395
+ "is_announcement_only" : True ,
396
+ "stream_post_policy" : 0 ,
397
+ "is_web_public" : True ,
398
+ "first_message_id" : None ,
399
+ }
400
+ )
401
+ return deepcopy (never_subscribed_streams )
402
+
403
+
342
404
@pytest .fixture
343
405
def realm_emojis () -> Dict [str , Dict [str , Any ]]:
344
406
# Omitting source_url, author_id (server version 3.0),
@@ -873,6 +935,8 @@ def initial_data(
873
935
logged_on_user : Dict [str , Any ],
874
936
users_fixture : List [Dict [str , Any ]],
875
937
streams_fixture : List [Dict [str , Any ]],
938
+ unsubscribed_streams_fixture : List [Subscription ],
939
+ never_subscribed_streams_fixture : List [Stream ],
876
940
realm_emojis : Dict [str , Dict [str , Any ]],
877
941
custom_profile_fields_fixture : List [Dict [str , Union [str , int ]]],
878
942
) -> Dict [str , Any ]:
@@ -884,24 +948,7 @@ def initial_data(
884
948
"email" : logged_on_user ["email" ],
885
949
"user_id" : logged_on_user ["user_id" ],
886
950
"realm_name" : "Test Organization Name" ,
887
- "unsubscribed" : [
888
- {
889
- "audible_notifications" : False ,
890
- "description" : "announce" ,
891
- "stream_id" : 7 ,
892
- "is_old_stream" : True ,
893
- "desktop_notifications" : False ,
894
- "pin_to_top" : False ,
895
- "stream_weekly_traffic" : 0 ,
896
- "invite_only" : False ,
897
- "name" : "announce" ,
898
- "push_notifications" : False ,
899
- "email_address" : "" ,
900
- "color" : "#bfd56f" ,
901
- "is_muted" : False ,
902
- "history_public_to_subscribers" : True ,
903
- }
904
- ],
951
+ "unsubscribed" : unsubscribed_streams_fixture ,
905
952
"result" : "success" ,
906
953
"queue_id" : "1522420755:786" ,
907
954
"realm_users" : users_fixture ,
@@ -950,24 +997,7 @@ def initial_data(
950
997
"subscriptions" : streams_fixture ,
951
998
"msg" : "" ,
952
999
"max_message_id" : 552761 ,
953
- "never_subscribed" : [
954
- {
955
- "invite_only" : False ,
956
- "description" : "Announcements from the Zulip GCI Mentors" ,
957
- "stream_id" : 87 ,
958
- "name" : "GCI announce" ,
959
- "is_old_stream" : True ,
960
- "stream_weekly_traffic" : 0 ,
961
- },
962
- {
963
- "invite_only" : False ,
964
- "description" : "General discussion" ,
965
- "stream_id" : 74 ,
966
- "name" : "GCI general" ,
967
- "is_old_stream" : True ,
968
- "stream_weekly_traffic" : 0 ,
969
- },
970
- ],
1000
+ "never_subscribed" : never_subscribed_streams_fixture ,
971
1001
"unread_msgs" : {
972
1002
"pms" : [
973
1003
{"sender_id" : 1 , "unread_message_ids" : [1 , 2 ]},
@@ -1437,6 +1467,26 @@ def stream_dict(streams_fixture: List[Dict[str, Any]]) -> Dict[int, Any]:
1437
1467
return {stream ["stream_id" ]: stream for stream in streams_fixture }
1438
1468
1439
1469
1470
+ @pytest .fixture
1471
+ def unsubscribed_streams (
1472
+ unsubscribed_streams_fixture : List [Subscription ],
1473
+ ) -> Dict [int , Subscription ]:
1474
+ return {
1475
+ unsubscribed_stream ["stream_id" ]: unsubscribed_stream
1476
+ for unsubscribed_stream in unsubscribed_streams_fixture
1477
+ }
1478
+
1479
+
1480
+ @pytest .fixture
1481
+ def never_subscribed_streams (
1482
+ never_subscribed_streams_fixture : List [Stream ],
1483
+ ) -> Dict [int , Stream ]:
1484
+ return {
1485
+ never_subscribed_stream ["stream_id" ]: never_subscribed_stream
1486
+ for never_subscribed_stream in never_subscribed_streams_fixture
1487
+ }
1488
+
1489
+
1440
1490
@pytest .fixture (
1441
1491
params = [
1442
1492
{
0 commit comments