@@ -549,45 +549,50 @@ def test__decode_message_id(
549
549
@pytest .mark .parametrize (
550
550
"link, expected_parsed_link" ,
551
551
[
552
- (
552
+ case (
553
553
SERVER_URL + "/#narrow/stream/1-Stream-1" ,
554
554
ParsedNarrowLink (
555
555
narrow = "stream" , stream = DecodedStream (stream_id = 1 , stream_name = None )
556
556
),
557
+ id = "modern_stream_narrow_link" ,
557
558
),
558
- (
559
+ case (
559
560
SERVER_URL + "/#narrow/stream/Stream.201" ,
560
561
ParsedNarrowLink (
561
562
narrow = "stream" ,
562
563
stream = DecodedStream (stream_id = None , stream_name = "Stream 1" ),
563
564
),
565
+ id = "deprecated_stream_narrow_link" ,
564
566
),
565
- (
567
+ case (
566
568
SERVER_URL + "/#narrow/stream/1-Stream-1/topic/foo.20bar" ,
567
569
ParsedNarrowLink (
568
570
narrow = "stream:topic" ,
569
571
topic_name = "foo bar" ,
570
572
stream = DecodedStream (stream_id = 1 , stream_name = None ),
571
573
),
574
+ id = "topic_narrow_link" ,
572
575
),
573
- (
576
+ case (
574
577
SERVER_URL + "/#narrow/stream/1-Stream-1/near/1" ,
575
578
ParsedNarrowLink (
576
579
narrow = "stream:near" ,
577
580
message_id = 1 ,
578
581
stream = DecodedStream (stream_id = 1 , stream_name = None ),
579
582
),
583
+ id = "stream_near_narrow_link" ,
580
584
),
581
- (
585
+ case (
582
586
SERVER_URL + "/#narrow/stream/1-Stream-1/topic/foo/near/1" ,
583
587
ParsedNarrowLink (
584
588
narrow = "stream:topic:near" ,
585
589
topic_name = "foo" ,
586
590
message_id = 1 ,
587
591
stream = DecodedStream (stream_id = 1 , stream_name = None ),
588
592
),
593
+ id = "topic_near_narrow_link" ,
589
594
),
590
- (
595
+ case (
591
596
SERVER_URL + "/#narrow/pm-with/1001,12-pm" ,
592
597
ParsedNarrowLink (
593
598
narrow = "pm-with" ,
@@ -597,8 +602,9 @@ def test__decode_message_id(
597
602
598
603
),
599
604
),
605
+ id = "pm_with_two_recipients_narrow_link" ,
600
606
),
601
- (
607
+ case (
602
608
SERVER_URL + "/#narrow/pm-with/1001,12-group" ,
603
609
ParsedNarrowLink (
604
610
narrow = "pm-with" ,
@@ -608,8 +614,9 @@ def test__decode_message_id(
608
614
609
615
),
610
616
),
617
+ id = "group_pm_with_two_recipients_narrow_link" ,
611
618
),
612
- (
619
+ case (
613
620
SERVER_URL + "/#narrow/pm-with/11-user11" ,
614
621
ParsedNarrowLink (
615
622
narrow = "pm-with" ,
@@ -619,8 +626,9 @@ def test__decode_message_id(
619
626
620
627
),
621
628
),
629
+ id = "pm_exposed_format_1_narrow_link" ,
622
630
),
623
- (
631
+ case (
624
632
SERVER_URL + "/#narrow/pm-with/6-bot-name" ,
625
633
ParsedNarrowLink (
626
634
narrow = "pm-with" ,
@@ -630,8 +638,9 @@ def test__decode_message_id(
630
638
631
639
),
632
640
),
641
+ id = "pm_with_bot_exposed_format_1_narrow_link" ,
633
642
),
634
- (
643
+ case (
635
644
SERVER_URL + "/#narrow/pm-with/1001,12-pm/near/1" ,
636
645
ParsedNarrowLink (
637
646
narrow = "pm-with:near" ,
@@ -642,8 +651,9 @@ def test__decode_message_id(
642
651
643
652
),
644
653
),
654
+ id = "common_pm_near_narrow_link" ,
645
655
),
646
- (
656
+ case (
647
657
SERVER_URL + "/#narrow/pm-with/1001,11,12-pm" ,
648
658
ParsedNarrowLink (
649
659
narrow = "pm-with" ,
@@ -657,8 +667,9 @@ def test__decode_message_id(
657
667
],
658
668
),
659
669
),
670
+ id = "pm_with_more_than_two_recipients_narrow_link" ,
660
671
),
661
- (
672
+ case (
662
673
SERVER_URL + "/#narrow/pm-with/1001,11,12-group" ,
663
674
ParsedNarrowLink (
664
675
narrow = "pm-with" ,
@@ -672,35 +683,34 @@ def test__decode_message_id(
672
683
],
673
684
),
674
685
),
686
+ id = "group_pm_with_more_than_two_recipients_narrow_link" ,
675
687
),
676
- (SERVER_URL + "/#narrow/foo" , ParsedNarrowLink ()),
677
- (SERVER_URL + "/#narrow/stream/" , ParsedNarrowLink ()),
678
- (SERVER_URL + "/#narrow/stream/1-Stream-1/topic/" , ParsedNarrowLink ()),
679
- (SERVER_URL + "/#narrow/stream/1-Stream-1//near/" , ParsedNarrowLink ()),
680
- (
688
+ case (
689
+ SERVER_URL + "/#narrow/foo" ,
690
+ ParsedNarrowLink (),
691
+ id = "invalid_narrow_link_1" ,
692
+ ),
693
+ case (
694
+ SERVER_URL + "/#narrow/stream/" ,
695
+ ParsedNarrowLink (),
696
+ id = "invalid_narrow_link_2" ,
697
+ ),
698
+ case (
699
+ SERVER_URL + "/#narrow/stream/1-Stream-1/topic/" ,
700
+ ParsedNarrowLink (),
701
+ id = "invalid_narrow_link_3" ,
702
+ ),
703
+ case (
704
+ SERVER_URL + "/#narrow/stream/1-Stream-1//near/" ,
705
+ ParsedNarrowLink (),
706
+ id = "invalid_narrow_link_4" ,
707
+ ),
708
+ case (
681
709
SERVER_URL + "/#narrow/stream/1-Stream-1/topic/foo/near/" ,
682
710
ParsedNarrowLink (),
711
+ id = "invalid_narrow_link_5" ,
683
712
),
684
713
],
685
- ids = [
686
- "modern_stream_narrow_link" ,
687
- "deprecated_stream_narrow_link" ,
688
- "topic_narrow_link" ,
689
- "stream_near_narrow_link" ,
690
- "topic_near_narrow_link" ,
691
- "pm_with_two_recipients_narrow_link" ,
692
- "group_pm_with_two_recipients_narrow_link" ,
693
- "pm_exposed_format_1_narrow_link" ,
694
- "pm_with_bot_exposed_format_1_narrow_link" ,
695
- "common_pm_near_narrow_link" ,
696
- "pm_with_more_than_two_recipients_narrow_link" ,
697
- "group_pm_with_more_than_two_recipients_narrow_link" ,
698
- "invalid_narrow_link_1" ,
699
- "invalid_narrow_link_2" ,
700
- "invalid_narrow_link_3" ,
701
- "invalid_narrow_link_4" ,
702
- "invalid_narrow_link_5" ,
703
- ],
704
714
)
705
715
def test__parse_narrow_link (
706
716
self , link : str , expected_parsed_link : ParsedNarrowLink
@@ -1078,16 +1088,17 @@ def test__validate_pm_data(
1078
1088
"narrow_to_user_called" ,
1079
1089
],
1080
1090
[
1081
- (
1091
+ case (
1082
1092
ParsedNarrowLink (
1083
1093
narrow = "stream" ,
1084
1094
stream = DecodedStream (stream_id = 1 , stream_name = "Stream 1" ),
1085
1095
),
1086
1096
True ,
1087
1097
False ,
1088
1098
False ,
1099
+ id = "stream_narrow" ,
1089
1100
),
1090
- (
1101
+ case (
1091
1102
ParsedNarrowLink (
1092
1103
narrow = "stream:topic" ,
1093
1104
topic_name = "Foo" ,
@@ -1096,8 +1107,9 @@ def test__validate_pm_data(
1096
1107
False ,
1097
1108
True ,
1098
1109
False ,
1110
+ id = "topic_narrow" ,
1099
1111
),
1100
- (
1112
+ case (
1101
1113
ParsedNarrowLink (
1102
1114
narrow = "stream:near" ,
1103
1115
message_id = 1 ,
@@ -1106,8 +1118,9 @@ def test__validate_pm_data(
1106
1118
True ,
1107
1119
False ,
1108
1120
False ,
1121
+ id = "stream_near_narrow" ,
1109
1122
),
1110
- (
1123
+ case (
1111
1124
ParsedNarrowLink (
1112
1125
narrow = "stream:topic:near" ,
1113
1126
topic_name = "Foo" ,
@@ -1117,8 +1130,9 @@ def test__validate_pm_data(
1117
1130
False ,
1118
1131
True ,
1119
1132
False ,
1133
+ id = "topic_near_narrow" ,
1120
1134
),
1121
- (
1135
+ case (
1122
1136
ParsedNarrowLink (
1123
1137
narrow = "pm-with" ,
1124
1138
pm_with = DecodedPM (
@@ -1130,8 +1144,9 @@ def test__validate_pm_data(
1130
1144
False ,
1131
1145
False ,
1132
1146
True ,
1147
+ id = "pm_narrow" ,
1133
1148
),
1134
- (
1149
+ case (
1135
1150
ParsedNarrowLink (
1136
1151
narrow = "pm-with" ,
1137
1152
pm_with = DecodedPM (
@@ -1147,8 +1162,9 @@ def test__validate_pm_data(
1147
1162
False ,
1148
1163
False ,
1149
1164
True ,
1165
+ id = "group_pm_narrow" ,
1150
1166
),
1151
- (
1167
+ case (
1152
1168
ParsedNarrowLink (
1153
1169
narrow = "pm-with:near" ,
1154
1170
message_id = 1 ,
@@ -1161,8 +1177,9 @@ def test__validate_pm_data(
1161
1177
False ,
1162
1178
False ,
1163
1179
True ,
1180
+ id = "pm_near_narrow" ,
1164
1181
),
1165
- (
1182
+ case (
1166
1183
ParsedNarrowLink (
1167
1184
narrow = "pm-with:near" ,
1168
1185
message_id = 1 ,
@@ -1179,18 +1196,9 @@ def test__validate_pm_data(
1179
1196
False ,
1180
1197
False ,
1181
1198
True ,
1199
+ id = "group_pm_near_narrow" ,
1182
1200
),
1183
1201
],
1184
- ids = [
1185
- "stream_narrow" ,
1186
- "topic_narrow" ,
1187
- "stream_near_narrow" ,
1188
- "topic_near_narrow" ,
1189
- "pm_narrow" ,
1190
- "group_pm_narrow" ,
1191
- "pm_near_narrow" ,
1192
- "group_pm_near_narrow" ,
1193
- ],
1194
1202
)
1195
1203
def test__switch_narrow_to (
1196
1204
self ,
0 commit comments