@@ -612,6 +612,7 @@ def test__parse_narrow_link(
612
612
[
613
613
"parsed_link" ,
614
614
"is_user_subscribed_to_stream" ,
615
+ "is_valid_private_recipient" ,
615
616
"is_valid_stream" ,
616
617
"topics_in_stream" ,
617
618
"expected_error" ,
@@ -624,6 +625,7 @@ def test__parse_narrow_link(
624
625
True ,
625
626
None ,
626
627
None ,
628
+ None ,
627
629
"" ,
628
630
id = "valid_modern_stream_narrow_parsed_link" ,
629
631
),
@@ -635,6 +637,7 @@ def test__parse_narrow_link(
635
637
False ,
636
638
None ,
637
639
None ,
640
+ None ,
638
641
"The stream seems to be either unknown or unsubscribed" ,
639
642
id = "invalid_modern_stream_narrow_parsed_link" ,
640
643
),
@@ -644,6 +647,7 @@ def test__parse_narrow_link(
644
647
stream = DecodedStream (stream_id = None , stream_name = "Stream 1" ),
645
648
),
646
649
None ,
650
+ None ,
647
651
True ,
648
652
None ,
649
653
"" ,
@@ -655,6 +659,7 @@ def test__parse_narrow_link(
655
659
stream = DecodedStream (stream_id = None , stream_name = "foo" ),
656
660
),
657
661
None ,
662
+ None ,
658
663
False ,
659
664
None ,
660
665
"The stream seems to be either unknown or unsubscribed" ,
@@ -668,6 +673,7 @@ def test__parse_narrow_link(
668
673
),
669
674
True ,
670
675
None ,
676
+ None ,
671
677
["Valid" ],
672
678
"" ,
673
679
id = "valid_topic_narrow_parsed_link" ,
@@ -680,6 +686,7 @@ def test__parse_narrow_link(
680
686
),
681
687
True ,
682
688
None ,
689
+ None ,
683
690
[],
684
691
"Invalid topic name" ,
685
692
id = "invalid_topic_narrow_parsed_link" ,
@@ -693,6 +700,7 @@ def test__parse_narrow_link(
693
700
True ,
694
701
None ,
695
702
None ,
703
+ None ,
696
704
"" ,
697
705
id = "valid_stream_near_narrow_parsed_link" ,
698
706
),
@@ -705,6 +713,7 @@ def test__parse_narrow_link(
705
713
True ,
706
714
None ,
707
715
None ,
716
+ None ,
708
717
"Invalid message ID" ,
709
718
id = "invalid_stream_near_narrow_parsed_link" ,
710
719
),
@@ -717,6 +726,7 @@ def test__parse_narrow_link(
717
726
),
718
727
True ,
719
728
None ,
729
+ None ,
720
730
["Valid" ],
721
731
"" ,
722
732
id = "valid_topic_near_narrow_parsed_link" ,
@@ -730,6 +740,7 @@ def test__parse_narrow_link(
730
740
),
731
741
True ,
732
742
None ,
743
+ None ,
733
744
["Valid" ],
734
745
"Invalid message ID" ,
735
746
id = "invalid_topic_near_narrow_parsed_link" ,
@@ -739,6 +750,7 @@ def test__parse_narrow_link(
739
750
None ,
740
751
None ,
741
752
None ,
753
+ None ,
742
754
"The narrow link seems to be either broken or unsupported" ,
743
755
id = "invalid_narrow_link" ,
744
756
),
@@ -749,6 +761,7 @@ def test__parse_narrow_link(
749
761
True ,
750
762
None ,
751
763
None ,
764
+ None ,
752
765
"" ,
753
766
id = "valid_stream_data_with_stream_id" ,
754
767
),
@@ -760,6 +773,7 @@ def test__parse_narrow_link(
760
773
False ,
761
774
None ,
762
775
None ,
776
+ None ,
763
777
"The stream seems to be either unknown or unsubscribed" ,
764
778
id = "invalid_stream_data_with_stream_id" ,
765
779
),
@@ -769,6 +783,7 @@ def test__parse_narrow_link(
769
783
stream = DecodedStream (stream_id = None , stream_name = "Stream 1" ),
770
784
), # ...
771
785
None ,
786
+ None ,
772
787
True ,
773
788
None ,
774
789
"" ,
@@ -780,18 +795,62 @@ def test__parse_narrow_link(
780
795
stream = DecodedStream (stream_id = None , stream_name = "foo" ),
781
796
), # ...
782
797
None ,
798
+ None ,
783
799
False ,
784
800
None ,
785
801
"The stream seems to be either unknown or unsubscribed" ,
786
802
id = "invalid_stream_data_with_stream_name" ,
787
803
),
804
+ case (
805
+ ParsedNarrowLink (
806
+ narrow = "pm_with" ,
807
+ pm_with = DecodedPM (
808
+ type = None , recipient_ids = [1001 , 11 ], recipient_emails = None
809
+ ),
810
+ ), # ...
811
+ None ,
812
+ True ,
813
+ None ,
814
+ None ,
815
+ "" ,
816
+ id = "valid_pm_data" ,
817
+ ),
818
+ case (
819
+ ParsedNarrowLink (
820
+ narrow = "pm_with" ,
821
+ pm_with = DecodedPM (
822
+ type = None , recipient_ids = [1001 , 11 , 12 ], recipient_emails = None
823
+ ),
824
+ ), # ...
825
+ None ,
826
+ True ,
827
+ None ,
828
+ None ,
829
+ "" ,
830
+ id = "valid_group_pm_data" ,
831
+ ),
832
+ case (
833
+ ParsedNarrowLink (
834
+ narrow = "pm_with" ,
835
+ pm_with = DecodedPM (
836
+ type = None , recipient_ids = [1001 , - 1 ], recipient_emails = None
837
+ ),
838
+ ), # ...
839
+ None ,
840
+ False ,
841
+ None ,
842
+ None ,
843
+ "The PM has one or more invalid recipient(s)" ,
844
+ id = "invalid_recipient" ,
845
+ ),
788
846
],
789
847
)
790
848
def test__validate_narrow_link (
791
849
self ,
792
850
stream_dict : Dict [int , Any ],
793
851
parsed_link : ParsedNarrowLink ,
794
852
is_user_subscribed_to_stream : Optional [bool ],
853
+ is_valid_private_recipient : Optional [bool ],
795
854
is_valid_stream : Optional [bool ],
796
855
topics_in_stream : Optional [List [str ]],
797
856
expected_error : str ,
@@ -800,6 +859,9 @@ def test__validate_narrow_link(
800
859
self .controller .model .is_user_subscribed_to_stream .return_value = (
801
860
is_user_subscribed_to_stream
802
861
)
862
+ self .controller .model .is_valid_private_recipient .return_value = (
863
+ is_valid_private_recipient
864
+ )
803
865
self .controller .model .is_valid_stream .return_value = is_valid_stream
804
866
self .controller .model .topics_in_stream .return_value = topics_in_stream
805
867
mocked_button = self .message_link_button ()
0 commit comments