@@ -2080,6 +2080,99 @@ def test_notify_users_hides_PM_content_based_on_user_setting(
2080
2080
f"Test Organization Name:\n Foo Foo (to you{ others } )" , expected_content
2081
2081
)
2082
2082
2083
+ @pytest .mark .parametrize (
2084
+ [
2085
+ "user_id" ,
2086
+ "flags" ,
2087
+ "visual_notification_status" ,
2088
+ "display_recipient" ,
2089
+ "subject" ,
2090
+ "is_stream_muted" ,
2091
+ "is_topic_muted" ,
2092
+ "no_of_times_notify_call_expected" ,
2093
+ ],
2094
+ [
2095
+ (
2096
+ 4444 ,
2097
+ {"flags" : ["has_alert_word" ]},
2098
+ True ,
2099
+ {"display_recipient" : ["test_here" ]},
2100
+ {"subject" : ["k1" ]},
2101
+ True ,
2102
+ True ,
2103
+ 1 ,
2104
+ ),
2105
+ (
2106
+ 4444 ,
2107
+ {"flags" : ["has_alert_word" ]},
2108
+ False ,
2109
+ {"display_recipient" : ["test_here" ]},
2110
+ {"subject" : ["k1" ]},
2111
+ True ,
2112
+ True ,
2113
+ 0 ,
2114
+ ),
2115
+ (
2116
+ 4444 ,
2117
+ {"flags" : ["has_alert_word" ]},
2118
+ False ,
2119
+ {"display_recipient" : ["test_here" ]},
2120
+ {"subject" : ["k1" ]},
2121
+ True ,
2122
+ False ,
2123
+ 0 ,
2124
+ ),
2125
+ (
2126
+ 4444 ,
2127
+ {"flags" : ["has_alert_word" ]},
2128
+ False ,
2129
+ {"display_recipient" : ["test_here" ]},
2130
+ {"subject" : ["k1" ]},
2131
+ False ,
2132
+ False ,
2133
+ 1 ,
2134
+ ),
2135
+ ],
2136
+ ids = [
2137
+ "visual_notification is on -> no effect due to mute" ,
2138
+ "visual_notification is off, and both topic and stream is muted" ,
2139
+ "visual_notification is off, only topic is muted" ,
2140
+ "visual_notification is off, neither topic or stream is muted" ,
2141
+ ],
2142
+ )
2143
+ def test_notify_user_with_alert_words (
2144
+ self ,
2145
+ mocker ,
2146
+ model ,
2147
+ stream_msg_fixture ,
2148
+ user_id ,
2149
+ flags ,
2150
+ visual_notification_status ,
2151
+ display_recipient ,
2152
+ subject ,
2153
+ is_stream_muted ,
2154
+ is_topic_muted ,
2155
+ no_of_times_notify_call_expected ,
2156
+ ):
2157
+ stream_msg_fixture .update (flags )
2158
+ self .controller .notify_enabled = True
2159
+ stream_msg_fixture .update (display_recipient )
2160
+ stream_msg_fixture .update (subject )
2161
+ mocker .patch .object (
2162
+ model ,
2163
+ "is_visual_notifications_enabled" ,
2164
+ return_value = visual_notification_status ,
2165
+ )
2166
+ mocker .patch .object (model , "is_muted_stream" , return_value = is_stream_muted )
2167
+ mocker .patch .object (model , "is_muted_topic" , return_value = is_topic_muted )
2168
+ notify = mocker .patch (MODULE + ".notify" )
2169
+ model .notify_user (stream_msg_fixture )
2170
+ if no_of_times_notify_call_expected == 1 :
2171
+ assert notify .called
2172
+ else :
2173
+ assert not notify .called
2174
+ # recipient = notify.call_args[0][0]
2175
+
2083
2176
@pytest .mark .parametrize (
2084
2177
"event, initially_me_message,"
2085
2178
"expected_times_messages_rerendered, expected_index, topic_view_enabled" ,
0 commit comments