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