@@ -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,16 +750,107 @@ 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
),
757
+ case (
758
+ ParsedNarrowLink (
759
+ narrow = "stream" , stream = DecodedStream (stream_id = 1 , stream_name = None )
760
+ ), # ...
761
+ True ,
762
+ None ,
763
+ None ,
764
+ None ,
765
+ "" ,
766
+ id = "valid_stream_data_with_stream_id" ,
767
+ ),
768
+ case (
769
+ ParsedNarrowLink (
770
+ narrow = "stream" ,
771
+ stream = DecodedStream (stream_id = 462 , stream_name = None ),
772
+ ), # ...
773
+ False ,
774
+ None ,
775
+ None ,
776
+ None ,
777
+ "The stream seems to be either unknown or unsubscribed" ,
778
+ id = "invalid_stream_data_with_stream_id" ,
779
+ ),
780
+ case (
781
+ ParsedNarrowLink (
782
+ narrow = "stream" ,
783
+ stream = DecodedStream (stream_id = None , stream_name = "Stream 1" ),
784
+ ), # ...
785
+ None ,
786
+ None ,
787
+ True ,
788
+ None ,
789
+ "" ,
790
+ id = "valid_stream_data_with_stream_name" ,
791
+ ),
792
+ case (
793
+ ParsedNarrowLink (
794
+ narrow = "stream" ,
795
+ stream = DecodedStream (stream_id = None , stream_name = "foo" ),
796
+ ), # ...
797
+ None ,
798
+ None ,
799
+ False ,
800
+ None ,
801
+ "The stream seems to be either unknown or unsubscribed" ,
802
+ id = "invalid_stream_data_with_stream_name" ,
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
+ ),
745
846
],
746
847
)
747
848
def test__validate_narrow_link (
748
849
self ,
749
850
stream_dict : Dict [int , Any ],
750
851
parsed_link : ParsedNarrowLink ,
751
852
is_user_subscribed_to_stream : Optional [bool ],
853
+ is_valid_private_recipient : Optional [bool ],
752
854
is_valid_stream : Optional [bool ],
753
855
topics_in_stream : Optional [List [str ]],
754
856
expected_error : str ,
@@ -757,6 +859,9 @@ def test__validate_narrow_link(
757
859
self .controller .model .is_user_subscribed_to_stream .return_value = (
758
860
is_user_subscribed_to_stream
759
861
)
862
+ self .controller .model .is_valid_private_recipient .return_value = (
863
+ is_valid_private_recipient
864
+ )
760
865
self .controller .model .is_valid_stream .return_value = is_valid_stream
761
866
self .controller .model .topics_in_stream .return_value = topics_in_stream
762
867
mocked_button = self .message_link_button ()
0 commit comments