@@ -834,78 +834,130 @@ def test_update_private_message(
834
834
],
835
835
)
836
836
@pytest .mark .parametrize (
837
- "req, old_topic, footer_updated" ,
837
+ "test_id, req, old_topic, new_topic, stream_name, propagate_mode , footer_updated" ,
838
838
[
839
839
(
840
+ 1 ,
840
841
{
841
842
"message_id" : 1 ,
842
843
"propagate_mode" : "change_one" ,
843
844
"content" : "hi!" ,
844
845
"topic" : "Some topic" ,
845
846
},
846
847
"Some topic" ,
848
+ "Some topic" ,
849
+ "stream" ,
850
+ "change_one" ,
847
851
False ,
848
852
),
849
853
(
854
+ 2 ,
850
855
{
851
856
"message_id" : 1 ,
852
857
"propagate_mode" : "change_one" ,
853
858
"topic" : "Topic change" ,
854
859
},
855
860
"Old topic" ,
861
+ "Topic change" ,
862
+ "stream" ,
863
+ "change_one" ,
856
864
True ,
857
865
),
858
866
(
859
- {"message_id" : 1 , "propagate_mode" : "change_all" , "topic" : "Old topic" },
867
+ 3 ,
868
+ {
869
+ "message_id" : 1 ,
870
+ "propagate_mode" : "change_all" ,
871
+ "topic" : "Old topic" ,
872
+ },
873
+ "Old topic" ,
860
874
"Old topic" ,
875
+ "stream" ,
876
+ "change_one" ,
861
877
False ,
862
878
),
863
879
(
880
+ 4 ,
864
881
{
865
882
"message_id" : 1 ,
866
883
"propagate_mode" : "change_later" ,
867
884
"content" : ":smile:" ,
868
885
"topic" : "terminal" ,
869
886
},
870
887
"terminal" ,
888
+ "terminal" ,
889
+ "stream" ,
890
+ "change_later" ,
871
891
False ,
872
892
),
873
893
(
894
+ 5 ,
874
895
{
875
896
"message_id" : 1 ,
876
897
"propagate_mode" : "change_one" ,
877
898
"content" : "Hey!" ,
878
899
"topic" : "grett" ,
879
900
},
880
901
"greet" ,
902
+ "grett" ,
903
+ "stream" ,
904
+ "change_one" ,
881
905
True ,
882
906
),
883
907
(
908
+ 6 ,
884
909
{
885
910
"message_id" : 1 ,
886
911
"propagate_mode" : "change_all" ,
887
912
"content" : "Lets party!" ,
888
913
"topic" : "party" ,
889
914
},
890
915
"lets_party" ,
916
+ "party" ,
917
+ "stream" ,
918
+ "change_all" ,
891
919
True ,
892
920
),
893
921
],
894
922
)
895
923
def test_update_stream_message (
896
- self , mocker , model , response , return_value , req , old_topic , footer_updated
924
+ self ,
925
+ mocker ,
926
+ model ,
927
+ response ,
928
+ return_value ,
929
+ test_id ,
930
+ req ,
931
+ old_topic ,
932
+ new_topic ,
933
+ stream_name ,
934
+ propagate_mode ,
935
+ footer_updated ,
897
936
):
898
937
self .client .update_message = mocker .Mock (return_value = response )
899
938
model .index ["messages" ][req ["message_id" ]]["subject" ] = old_topic
939
+ req ["topic" ] = new_topic
940
+ model .index ["messages" ][req ["message_id" ]]["display_recipient" ] = stream_name
941
+ req ["propagate_mode" ] = propagate_mode
900
942
901
943
result = model .update_stream_message (** req )
902
-
903
944
self .client .update_message .assert_called_once_with (req )
904
945
assert result == return_value
905
946
self .display_error_if_present .assert_called_once_with (response , self .controller )
906
947
report_success = model .controller .report_success
907
948
if result and footer_updated :
908
- report_success .assert_called_once_with ("You changed a message's topic." )
949
+ if propagate_mode == "change_one" :
950
+ report_success .assert_called_once_with (
951
+ f"You changed one message's topic from #{ stream_name } > { old_topic } to #{ stream_name } > { new_topic } ."
952
+ )
953
+ elif propagate_mode == "change_later" :
954
+ report_success .assert_called_once_with (
955
+ f"You changed some messages' topic from #{ stream_name } > { old_topic } to #{ stream_name } > { new_topic } ."
956
+ )
957
+ else :
958
+ report_success .assert_called_once_with (
959
+ f"You changed all messages' topic from #{ stream_name } > { old_topic } to #{ stream_name } > { new_topic } ."
960
+ )
909
961
else :
910
962
report_success .assert_not_called ()
911
963
0 commit comments