@@ -2048,6 +2048,99 @@ def test_notify_users_hides_PM_content_based_on_user_setting(
2048
2048
f"Test Organization Name:\n Foo Foo (to you{ others } )" , expected_content
2049
2049
)
2050
2050
2051
+ @pytest .mark .parametrize (
2052
+ [
2053
+ "user_id" ,
2054
+ "flags" ,
2055
+ "visual_notification_status" ,
2056
+ "display_recipient" ,
2057
+ "subject" ,
2058
+ "is_stream_muted" ,
2059
+ "is_topic_muted" ,
2060
+ "no_of_times_notify_call_expected" ,
2061
+ ],
2062
+ [
2063
+ (
2064
+ 4444 ,
2065
+ {"flags" : ["has_alert_word" ]},
2066
+ True ,
2067
+ {"display_recipient" : ["test_here" ]},
2068
+ {"subject" : ["k1" ]},
2069
+ True ,
2070
+ True ,
2071
+ 1 ,
2072
+ ),
2073
+ (
2074
+ 4444 ,
2075
+ {"flags" : ["has_alert_word" ]},
2076
+ False ,
2077
+ {"display_recipient" : ["test_here" ]},
2078
+ {"subject" : ["k1" ]},
2079
+ True ,
2080
+ True ,
2081
+ 0 ,
2082
+ ),
2083
+ (
2084
+ 4444 ,
2085
+ {"flags" : ["has_alert_word" ]},
2086
+ False ,
2087
+ {"display_recipient" : ["test_here" ]},
2088
+ {"subject" : ["k1" ]},
2089
+ True ,
2090
+ False ,
2091
+ 0 ,
2092
+ ),
2093
+ (
2094
+ 4444 ,
2095
+ {"flags" : ["has_alert_word" ]},
2096
+ False ,
2097
+ {"display_recipient" : ["test_here" ]},
2098
+ {"subject" : ["k1" ]},
2099
+ False ,
2100
+ False ,
2101
+ 1 ,
2102
+ ),
2103
+ ],
2104
+ ids = [
2105
+ "visual_notification is on -> no effect due to mute" ,
2106
+ "visual_notification is off, and both topic and stream is muted" ,
2107
+ "visual_notification is off, only topic is muted" ,
2108
+ "visual_notification is off, neither topic or stream is muted" ,
2109
+ ],
2110
+ )
2111
+ def test_notify_user_with_alert_words (
2112
+ self ,
2113
+ mocker ,
2114
+ model ,
2115
+ stream_msg_fixture ,
2116
+ user_id ,
2117
+ flags ,
2118
+ visual_notification_status ,
2119
+ display_recipient ,
2120
+ subject ,
2121
+ is_stream_muted ,
2122
+ is_topic_muted ,
2123
+ no_of_times_notify_call_expected ,
2124
+ ):
2125
+ stream_msg_fixture .update (flags )
2126
+ self .controller .notify_enabled = True
2127
+ stream_msg_fixture .update (display_recipient )
2128
+ stream_msg_fixture .update (subject )
2129
+ mocker .patch .object (
2130
+ model ,
2131
+ "is_visual_notifications_enabled" ,
2132
+ return_value = visual_notification_status ,
2133
+ )
2134
+ mocker .patch .object (model , "is_muted_stream" , return_value = is_stream_muted )
2135
+ mocker .patch .object (model , "is_muted_topic" , return_value = is_topic_muted )
2136
+ notify = mocker .patch (MODULE + ".notify" )
2137
+ model .notify_user (stream_msg_fixture )
2138
+ if no_of_times_notify_call_expected == 1 :
2139
+ assert notify .called
2140
+ else :
2141
+ assert not notify .called
2142
+ # recipient = notify.call_args[0][0]
2143
+
2051
2144
@pytest .mark .parametrize (
2052
2145
"event, expected_times_messages_rerendered, expected_index, topic_view_enabled" ,
2053
2146
[
0 commit comments