@@ -827,7 +827,7 @@ def test_update_private_message(
827
827
],
828
828
)
829
829
@pytest .mark .parametrize (
830
- "req, old_topic, footer_updated" ,
830
+ "req, old_topic, new_topic, stream_name, no_of_messages, footer_updated" ,
831
831
[
832
832
(
833
833
{
@@ -837,6 +837,15 @@ def test_update_private_message(
837
837
"topic" : "Some topic" ,
838
838
},
839
839
"Some topic" ,
840
+ "Some topic" ,
841
+ "stream" ,
842
+ {
843
+ "1" : 1 ,
844
+ "2" : 2 ,
845
+ "3" : 3 ,
846
+ "4" : 4 ,
847
+ "5" : 5 ,
848
+ },
840
849
False ,
841
850
),
842
851
(
@@ -846,11 +855,33 @@ def test_update_private_message(
846
855
"topic" : "Topic change" ,
847
856
},
848
857
"Old topic" ,
858
+ "Topic change" ,
859
+ "stream" ,
860
+ {
861
+ "1" : 1 ,
862
+ "2" : 2 ,
863
+ "3" : 3 ,
864
+ "4" : 4 ,
865
+ "5" : 5 ,
866
+ },
849
867
True ,
850
868
),
851
869
(
852
- {"message_id" : 1 , "propagate_mode" : "change_all" , "topic" : "Old topic" },
870
+ {
871
+ "message_id" : 1 ,
872
+ "propagate_mode" : "change_all" ,
873
+ "topic" : "Old topic" ,
874
+ },
875
+ "Old topic" ,
853
876
"Old topic" ,
877
+ "stream" ,
878
+ {
879
+ "1" : 1 ,
880
+ "2" : 2 ,
881
+ "3" : 3 ,
882
+ "4" : 4 ,
883
+ "5" : 5 ,
884
+ },
854
885
False ,
855
886
),
856
887
(
@@ -861,6 +892,15 @@ def test_update_private_message(
861
892
"topic" : "terminal" ,
862
893
},
863
894
"terminal" ,
895
+ "terminal" ,
896
+ "stream" ,
897
+ {
898
+ "1" : 1 ,
899
+ "2" : 2 ,
900
+ "3" : 3 ,
901
+ "4" : 4 ,
902
+ "5" : 5 ,
903
+ },
864
904
False ,
865
905
),
866
906
(
@@ -871,6 +911,15 @@ def test_update_private_message(
871
911
"topic" : "grett" ,
872
912
},
873
913
"greet" ,
914
+ "grett" ,
915
+ "stream" ,
916
+ {
917
+ "1" : 1 ,
918
+ "2" : 2 ,
919
+ "3" : 3 ,
920
+ "4" : 4 ,
921
+ "5" : 5 ,
922
+ },
874
923
True ,
875
924
),
876
925
(
@@ -881,15 +930,37 @@ def test_update_private_message(
881
930
"topic" : "party" ,
882
931
},
883
932
"lets_party" ,
933
+ "party" ,
934
+ "stream" ,
935
+ {
936
+ "1" : 1 ,
937
+ "2" : 2 ,
938
+ "3" : 3 ,
939
+ "4" : 4 ,
940
+ "5" : 5 ,
941
+ },
884
942
True ,
885
943
),
886
944
],
887
945
)
888
946
def test_update_stream_message (
889
- self , mocker , model , response , return_value , req , old_topic , footer_updated
947
+ self ,
948
+ mocker ,
949
+ model ,
950
+ response ,
951
+ return_value ,
952
+ req ,
953
+ old_topic ,
954
+ new_topic ,
955
+ stream_name ,
956
+ no_of_messages ,
957
+ footer_updated ,
890
958
):
891
959
self .client .update_message = mocker .Mock (return_value = response )
892
960
model .index ["messages" ][req ["message_id" ]]["subject" ] = old_topic
961
+ req ["topic" ] = new_topic
962
+ model .index ["messages" ][req ["message_id" ]]["display_recipient" ] = stream_name
963
+ model .index ["edited_messages" ] = no_of_messages
893
964
894
965
result = model .update_stream_message (** req )
895
966
@@ -898,7 +969,19 @@ def test_update_stream_message(
898
969
self .display_error_if_present .assert_called_once_with (response , self .controller )
899
970
report_success = model .controller .report_success
900
971
if result and footer_updated :
901
- report_success .assert_called_once_with ("You changed a message's topic." )
972
+ report_success .assert_called_once_with (
973
+ "You changed "
974
+ + str (len (no_of_messages ))
975
+ + " message's topic from #"
976
+ + stream_name
977
+ + " > "
978
+ + old_topic
979
+ + " to #"
980
+ + stream_name
981
+ + " > "
982
+ + new_topic
983
+ + "."
984
+ )
902
985
else :
903
986
report_success .assert_not_called ()
904
987
0 commit comments