-
-
Notifications
You must be signed in to change notification settings - Fork 268
/
Copy pathconftest.py
1540 lines (1402 loc) · 44 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from collections import OrderedDict, defaultdict
from copy import deepcopy
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union
import pytest
from pytest_mock import MockerFixture
from urwid import Widget
from zulipterminal.api_types import (
CustomFieldValue,
CustomProfileField,
Message,
MessageType,
)
from zulipterminal.config.keys import (
ZT_TO_URWID_CMD_MAPPING,
keys_for_command,
primary_key_for_command,
)
from zulipterminal.helper import (
CustomProfileData,
Index,
MinimalUserData,
TidiedUserInfo,
)
from zulipterminal.helper import initial_index as helper_initial_index
from zulipterminal.ui_tools.buttons import StreamButton, TopicButton, UserButton
from zulipterminal.ui_tools.messages import MessageBox
from zulipterminal.urwid_types import urwid_Size
from zulipterminal.version import (
MINIMUM_SUPPORTED_SERVER_VERSION,
SUPPORTED_SERVER_VERSIONS,
)
# --------------- Autouse Fixtures -----------------------------------------
@pytest.fixture(autouse=True)
def no_requests(monkeypatch: pytest.MonkeyPatch) -> None:
"""
Forces all the tests to work offline.
"""
monkeypatch.delattr("requests.sessions.Session.request")
@pytest.fixture(autouse=True)
def no_asynch(mocker: MockerFixture) -> None:
"""
Make all function calls synchronous.
"""
mocker.patch("zulipterminal.helper.asynch")
# --------------- Controller Fixtures -----------------------------------------
@pytest.fixture
def stream_button(mocker: MockerFixture) -> StreamButton:
"""
Mocked stream button.
"""
view_mock = mocker.Mock()
view_mock.palette = [(None, "black", "white")]
button = StreamButton(
properties={
"name": "PTEST",
"id": 205,
"color": "#bfd56f",
"stream_access_type": "public",
"description": "Test stream description",
},
controller=mocker.patch("zulipterminal.core.Controller"),
view=view_mock,
count=30,
)
return button
@pytest.fixture
def topic_button(mocker: MockerFixture) -> TopicButton:
"""
Mocked topic button.
"""
view_mock = mocker.Mock()
view_mock.palette = [(None, "black", "white")]
button = TopicButton(
stream_id=100,
topic="PTEST",
controller=mocker.patch("zulipterminal.core.Controller"),
view=view_mock,
count=30,
)
return button
@pytest.fixture
def user_button(mocker: MockerFixture) -> UserButton:
"""
Mocked User Button.
"""
return UserButton(
user={
"user_id": 5179,
"full_name": "Boo Boo",
"email": "[email protected]",
},
controller=mocker.patch("zulipterminal.core.Controller"),
view=mocker.patch("zulipterminal.ui.View"),
state_marker="*",
count=0,
)
@pytest.fixture
def msg_box(
mocker: MockerFixture, messages_successful_response: Dict[str, Any]
) -> MessageBox:
"""
Mocked MessageBox with stream message
"""
model_mock = mocker.patch("zulipterminal.model.Model")
model_mock.stream_access_type.return_value = "public"
return MessageBox(
messages_successful_response["messages"][0],
model_mock,
None,
)
# --------------- Model Fixtures ----------------------------------------------
@pytest.fixture
def users_fixture(
logged_on_user: Dict[str, Any],
custom_profile_data_fixture: Dict[str, CustomFieldValue],
) -> List[Dict[str, Any]]:
users = [logged_on_user]
for i in range(1, 3):
users.append(
{
"user_id": 10 + i,
"full_name": f"Human {i}",
"email": f"person{i}@example.com",
"avatar_url": None,
"is_active": True,
"bot_type": None,
"is_bot": False,
"is_admin": False,
}
)
# Also add two users with the same name.
for i in range(1, 3):
users.append(
{
"user_id": 12 + i,
"full_name": "Human Duplicate",
"email": f"personduplicate{i}@example.com",
"avatar_url": None,
"is_active": True,
"bot_type": None,
"is_bot": False,
"is_admin": False,
}
)
# Add custom profile data to user 12
for user in users:
if user["user_id"] == 12:
user["profile_data"] = custom_profile_data_fixture
else:
user["profile_data"] = {}
return users
@pytest.fixture
def tidied_user_info_response(
clean_custom_profile_data_fixture: List[CustomProfileData],
) -> TidiedUserInfo:
# FIXME: Refactor this to use a more generic user?
return {
"full_name": "Human 2",
"email": "[email protected]",
"date_joined": "",
"timezone": "",
"is_bot": False,
"role": 400,
"bot_type": None,
"bot_owner_name": "",
"last_active": "",
"custom_profile_data": clean_custom_profile_data_fixture,
}
@pytest.fixture
def _all_users_by_id(initial_data: Dict[str, Any]) -> Dict[int, Any]:
return {
user["user_id"]: user
for user in (initial_data["realm_users"] + initial_data["cross_realm_bots"])
}
@pytest.fixture
def _cross_realm_bots_by_id(initial_data: Dict[str, Any]) -> Dict[int, Any]:
return {user["user_id"]: user for user in initial_data["cross_realm_bots"]}
@pytest.fixture
def user_groups_fixture() -> List[Dict[str, Any]]:
user_groups = []
members = [[1001, 11], [11, 12], [12], []]
for i in range(1, 5):
user_groups.append(
{
"id": 10 + i,
"name": f"Group {i}",
"description": f"Core developers of Group {i}",
"members": members[i - 1],
}
)
return user_groups
@pytest.fixture
def logged_on_user() -> Dict[str, Any]:
return {
"user_id": 1001,
"full_name": "Human Myself",
"email": "[email protected]",
}
@pytest.fixture
def general_stream() -> Dict[str, Any]:
return {
"name": "Some general stream",
"date_created": 1472091253,
"invite_only": False,
"color": "#b0a5fd", # Color in '#xxxxxx' format
"pin_to_top": False,
"stream_id": 1000,
"is_muted": 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,
}
# This is a private stream;
# only description/stream_id/invite_only/name/color vary from above
@pytest.fixture
def secret_stream() -> Dict[str, Any]:
return {
"description": "Some private stream",
"stream_id": 99,
"pin_to_top": False,
"invite_only": True,
"name": "Secret stream",
"date_created": 1472047124,
"email_address": "[email protected]",
"rendered_description": "Some private stream",
"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,
}
# Like public stream but with is_web_public=True
@pytest.fixture
def web_public_stream() -> Dict[str, Any]:
return {
"description": "Some web public stream",
"stream_id": 999,
"pin_to_top": False,
"invite_only": False,
"name": "Web public stream",
"date_created": 1472047124,
"email_address": "[email protected]",
"rendered_description": "Some web public stream",
"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,
}
@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]]:
streams = [general_stream, secret_stream, web_public_stream]
for i in range(1, 3):
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}",
"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,
}
)
return deepcopy(streams)
@pytest.fixture
def realm_emojis() -> Dict[str, Dict[str, Any]]:
# Omitting source_url, author_id (server version 3.0),
# author (server version < 3.0) since they are not used.
return {
"1": {
"deactivated": True,
"id": "1",
"name": "green_tick",
},
"202020": {
"deactivated": False,
"id": "202020",
"name": "joker",
},
"2": {
"deactivated": True,
"id": "2",
"name": "joy_cat",
},
"3": {
"deactivated": False,
"id": "3",
"name": "singing",
},
"4": {
"deactivated": False,
"id": "4",
"name": "zulip",
},
}
@pytest.fixture
def realm_emojis_data() -> "OrderedDict[str, Dict[str, Any]]":
return OrderedDict(
[
("joker", {"code": "202020", "aliases": [], "type": "realm_emoji"}),
("singing", {"code": "3", "aliases": [], "type": "realm_emoji"}),
("zulip", {"code": "4", "aliases": [], "type": "realm_emoji"}),
]
)
@pytest.fixture
def unicode_emojis() -> "OrderedDict[str, Dict[str, Any]]":
return OrderedDict(
[
(
"happy",
{"code": "1f600", "aliases": ["grinning"], "type": "unicode_emoji"},
),
("joker", {"code": "1f0cf", "aliases": [], "type": "unicode_emoji"}),
("joy_cat", {"code": "1f639", "aliases": [], "type": "unicode_emoji"}),
(
"rock_on",
{
"code": "1f918",
"aliases": ["sign_of_the_horns"],
"type": "unicode_emoji",
},
),
("smile", {"code": "263a", "aliases": [], "type": "unicode_emoji"}),
("smiley", {"code": "1f603", "aliases": [], "type": "unicode_emoji"}),
("smirk", {"code": "1f60f", "aliases": ["smug"], "type": "unicode_emoji"}),
("thumbs_up", {"code": "1f44d", "aliases": [], "type": "unicode_emoji"}),
]
)
@pytest.fixture
def zulip_emoji() -> "OrderedDict[str, Dict[str, Any]]":
return OrderedDict(
[
(
"zulip",
{"code": "zulip", "aliases": [], "type": "zulip_extra_emoji"},
)
]
)
def display_recipient_factory(
recipient_details_list: List[Tuple[int, str]]
) -> List[Dict[str, Any]]:
"""
Generate display_recipient field for (PM/group) messages
"""
return [
{
"id": _id,
"is_mirror_dummy": False,
"full_name": _name,
"email": f"{_name.split()[0]}@example.com",
}
for _id, _name in recipient_details_list
]
def msg_template_factory(
msg_id: int,
msg_type: MessageType,
timestamp: int,
*,
subject: str = "",
stream_id: Optional[int] = None,
recipients: Union[str, List[Dict[str, Any]]] = "PTEST",
) -> Message:
"""
Generate message template for all types of messages(stream/PM/group)
"""
# TODO: Separate Message into distinct types for stream and direct messages.
message = Message(
id=msg_id,
sender_full_name="Foo Foo",
timestamp=timestamp,
client="website",
type=msg_type,
sender_realm_str="",
flags=["read"],
sender_id=5140,
content_type="text/x-markdown",
subject=subject,
reactions=[],
subject_links=[],
avatar_url="dummy_avatar_url",
is_me_message=False,
content=f"{msg_type} content here.",
display_recipient=recipients,
)
if msg_type == "stream":
assert isinstance(stream_id, int)
assert isinstance(recipients, str)
message["stream_id"] = stream_id
else:
assert isinstance(recipients, list)
for _val in recipients:
assert isinstance(_val, dict)
return message
@pytest.fixture
def stream_msg_template() -> Message:
msg_template = msg_template_factory(
537286, "stream", 1520918722, subject="Test", stream_id=205
)
return msg_template
@pytest.fixture
def extra_stream_msg_template() -> Message:
msg_template = msg_template_factory(
537289, "stream", 1520918740, subject="Test", stream_id=205
)
return msg_template
@pytest.fixture
def pm_template() -> Message:
recipients = display_recipient_factory([(5179, "Boo Boo"), (5140, "Foo Foo")])
return msg_template_factory(537287, "private", 1520918736, recipients=recipients)
@pytest.fixture
def group_pm_template() -> Message:
recipients = display_recipient_factory(
[(5179, "Boo Boo"), (5140, "Foo Foo"), (5180, "Bar Bar")]
)
return msg_template_factory(537288, "private", 1520918737, recipients=recipients)
@pytest.fixture(params=["pm_template", "group_pm_template"])
def private_message_fixture(request: Any) -> Message:
return request.getfixturevalue(request.param)
@pytest.fixture(
params=["stream_msg_template", "pm_template", "group_pm_template"],
ids=["stream_message", "pm_message", "group_pm_message"],
)
def message_fixture(request: Any) -> Message:
"""
Acts as a parametrize fixture for stream msg, dms and group_pms.
"""
# `request` currently does not have an exported Pytest type.
# TODO: Use the exported type when it's made available.
template = request.getfixturevalue(request.param)
return template
@pytest.fixture
def messages_successful_response(
stream_msg_template: Message,
pm_template: Message,
group_pm_template: Message,
) -> Dict[str, Any]:
"""
A successful response from a /messages API query.
"""
return deepcopy(
{
"anchor": 10000000000000000,
"messages": [
stream_msg_template,
pm_template,
group_pm_template,
],
"result": "success",
"msg": "",
}
)
@pytest.fixture(
params=SUPPORTED_SERVER_VERSIONS,
ids=(lambda param: "server_version:{}-server_feature_level:{}".format(*param)),
)
def zulip_version(request: Any) -> Tuple[str, int]:
"""
Fixture to test different components based on the server version and the
feature level.
"""
return request.param
@pytest.fixture(
params=[
[
{
"content": "Hello!",
"timestamp": 1530129122,
"topic": "hello world",
"user_id": 1001,
# ...
}
],
[
{
"content": "Hello!",
"timestamp": 1530129122,
"topic": "party at my houz",
"user_id": 1001,
# ...
},
{
"content": "Howdy!",
"prev_content": "Hello!",
"prev_topic": "party at my houz",
"timestamp": 1530129134,
"topic": "party at my house",
"user_id": 1001,
# ...
},
],
],
ids=[
"unedited_message",
"edited_message",
],
)
def message_history(request: Any) -> List[Dict[str, Any]]:
"""
Returns message edit history for a message.
"""
return request.param
@pytest.fixture
def topics() -> List[str]:
return [
"Topic 1",
"This is a topic",
"Hello there!",
"He-llo there!",
"Hello t/here!",
"Hello from out-er_space!",
]
@pytest.fixture(
params=[
({537286}, {537286}),
({537286, 537287}, set()),
(set(), {537286, 537287}),
({537286, 537288}, {537287}),
({537287}, {537286, 537288}),
({537288}, {537286, 537287, 537288}),
({537286, 537287, 537288}, {537286}),
({537286, 537288}, {537286, 537288}),
],
ids=[
"stream_mention__stream_wildcard",
"stream+pm_mention__no_wildcard",
"no_mention__stream+pm_wildcard",
"stream+group_mention__pm_wildcard",
"pm_mention__stream+group_wildcard",
"group_mention__all_wildcard",
"all_mention__stream_wildcard",
"stream+group_mention__wildcard",
],
)
def mentioned_messages_combination(request: Any) -> Tuple[Set[int], Set[int]]:
"""
Returns a combination of mentioned and wildcard_mentioned messages
"""
return deepcopy(request.param)
@pytest.fixture
def custom_profile_fields_fixture() -> List[CustomProfileField]:
return [
{
# Short text: For one line responses, like "Job title".
# Responses are limited to 50 characters.
"id": 1,
"name": "Phone number",
"type": 1,
"hint": "",
"field_data": "",
"order": 1,
},
{
# Long text: For multiline responses, like "Biography".
"id": 2,
"name": "Biography",
"type": 2,
"hint": "What are you known for?",
"field_data": "",
"order": 2,
},
{
# Another example of Short text field.
"id": 3,
"name": "Favorite food",
"type": 1,
"hint": "Or drink, if you'd prefer",
"field_data": "",
"order": 3,
},
{
# List of options: Creates a dropdown with a list of options.
"id": 4,
"name": "Favorite editor",
"type": 3,
"hint": "",
"field_data": (
'{"0":{"text":"Vim","order":"1"},"1":{"text":"Emacs","order":"2"}}'
),
"order": 4,
},
{
# Date picker: For dates, like "Birthday".
"id": 5,
"name": "Birthday",
"type": 4,
"hint": "",
"field_data": "",
"order": 5,
},
{
# Link: For links to websites.
"id": 6,
"name": "Favorite website",
"type": 5,
"hint": "Or your personal blog's URL",
"field_data": "",
"order": 6,
},
{
# Person picker: For selecting one or more users,
# like "Manager" or "Direct reports".
"id": 7,
"name": "Manager",
"type": 6,
"hint": "Only one person",
"field_data": "",
"order": 7,
},
{
# Another person picker: Use case with multiple users.
"id": 8,
"name": "Mentor",
"type": 6,
"hint": "",
"field_data": "",
"order": 8,
},
{
# External account: For linking to GitHub, Twitter, etc.
# GitHub example
"id": 9,
"name": "GitHub username",
"type": 7,
"hint": "",
"field_data": '{"subtype":"github"}',
"order": 9,
},
{
# Twitter example
"id": 10,
"name": "Twitter username",
"type": 7,
"hint": "",
"field_data": '{"subtype":"twitter"}',
"order": 10,
},
{
# Custom example
"id": 11,
"name": "Reddit username",
"type": 7,
"hint": "",
"field_data": '{"subtype":"custom", "url_pattern":"https://www.reddit.com/u/%(username)s"}',
"order": 11,
},
{
# Pronouns: What pronouns should people use to refer to the user?
"id": 12,
"name": "Pronouns",
"type": 8,
"hint": "What pronouns should people use to refer to you?",
"field_data": "",
"order": 12,
},
]
@pytest.fixture
def custom_profile_data_fixture() -> Dict[str, CustomFieldValue]:
return {
"1": {"value": "6352813452", "rendered_value": "<p>6352813452</p>"},
"2": {
"value": "Simplicity\nThis is a multiline field",
"rendered_value": "<p>Simplicity\nThis is a multiline field</p>",
},
"3": {"value": "cola", "rendered_value": "<p>cola</p>"},
"4": {"value": "0"},
"5": {"value": "2023-04-22"},
"6": {"value": "https://www.google.com"},
"7": {"value": "[11]"},
"8": {"value": "[11, 13]"},
"9": {"value": "gitmaster"},
"10": {"value": "twittermaster"},
"11": {"value": "redditmaster"},
"12": {"value": "he/him"},
}
@pytest.fixture
def clean_custom_profile_data_fixture() -> List[CustomProfileData]:
return [
{
"label": "Phone number",
"value": "6352813452",
"type": 1,
"order": 1,
},
{
"label": "Biography",
"value": "Simplicity\nThis is a multiline field",
"type": 2,
"order": 2,
},
{
"label": "Favorite food",
"value": "cola",
"type": 1,
"order": 3,
},
{
"label": "Favorite editor",
"value": "Vim",
"type": 3,
"order": 4,
},
{
"label": "Birthday",
"value": "2023-04-22",
"type": 4,
"order": 5,
},
{
"label": "Favorite website",
"value": "https://www.google.com",
"type": 5,
"order": 6,
},
{
"label": "Manager",
"value": [11],
"type": 6,
"order": 7,
},
{
"label": "Mentor",
"value": [11, 13],
"type": 6,
"order": 8,
},
{
"label": "GitHub username",
"value": "https://github.com/gitmaster",
"type": 7,
"order": 9,
},
{
"label": "Twitter username",
"value": "https://twitter.com/twittermaster",
"type": 7,
"order": 10,
},
{
"label": "Reddit username",
"value": "https://www.reddit.com/u/redditmaster",
"type": 7,
"order": 11,
},
{
"label": "Pronouns",
"value": "he/him",
"type": 8,
"order": 12,
},
]
@pytest.fixture
def initial_data(
logged_on_user: Dict[str, Any],
users_fixture: List[Dict[str, Any]],
streams_fixture: List[Dict[str, Any]],
realm_emojis: Dict[str, Dict[str, Any]],
custom_profile_fields_fixture: List[Dict[str, Union[str, int]]],
) -> Dict[str, Any]:
"""
Response from /register API request.
"""
return {
"full_name": logged_on_user["full_name"],
"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,
}
],
"result": "success",
"queue_id": "1522420755:786",
"realm_users": users_fixture,
"cross_realm_bots": [
{
"full_name": "Notification Bot",
"timezone": "",
"is_bot": True,
"date_joined": "2015-12-28T19:58:29.035543+00:00",
"email": "[email protected]",
"user_id": 5,
"is_admin": False,
"avatar_url": "dummy_avatar_url",
},
{
"full_name": "Email Gateway",
"timezone": "",
"is_bot": True,
"date_joined": "2015-12-28T19:58:29.037658+00:00",
"email": "[email protected]",
"user_id": 6,
"is_admin": False,
"avatar_url": "dummy_avatar_url",
},
{
"full_name": "Welcome Bot",
"timezone": "",
"is_bot": True,
"date_joined": "2015-12-28T19:58:29.033231+00:00",
"email": "[email protected]",
"user_id": 4,
"is_admin": False,
"avatar_url": "dummy_avatar_url",
},
{
"full_name": "Zulip Feedback Bot",
"timezone": "",
"is_bot": True,
"date_joined": "2015-12-28T19:58:28.972281+00:00",
"email": "[email protected]",
"user_id": 1,
"is_admin": False,
"avatar_url": "dummy_avatar_url",
},
],
"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,
},
],
"unread_msgs": {
"pms": [
{"sender_id": 1, "unread_message_ids": [1, 2]},
{"sender_id": 2, "unread_message_ids": [3]},
],
"count": 0,
"mentions": [],
"streams": [
{
"stream_id": 1000,
"topic": "Some general unread topic",
"unread_message_ids": [4, 5, 6],
"sender_ids": [1, 2],
},
{
"stream_id": 99,
"topic": "Some private unread topic",
"unread_message_ids": [7],
"sender_ids": [1, 2],
},
],
"huddles": [
{"user_ids_string": "1001,11,12", "unread_message_ids": [11, 12, 13]},
{
"user_ids_string": "1001,11,12,13",
"unread_message_ids": [101, 102],
},
],
},
"presences": {