@@ -1978,25 +1978,72 @@ def test__update_topic_index(
1978
1978
"vary_each_msg" ,
1979
1979
"visual_notification_status" ,
1980
1980
"types_when_notify_called" ,
1981
+ "is_muted_stream" ,
1982
+ "is_muted_topic" ,
1981
1983
],
1982
1984
[
1983
1985
(
1984
1986
5140 ,
1985
1987
{"flags" : ["mentioned" , "wildcard_mentioned" ]},
1986
1988
True ,
1987
1989
[],
1990
+ None ,
1991
+ None ,
1988
1992
), # message_fixture sender_id is 5140
1989
- (5179 , {"flags" : ["mentioned" ]}, False , ["stream" , "private" ]),
1990
- (5179 , {"flags" : ["wildcard_mentioned" ]}, False , ["stream" , "private" ]),
1991
- (5179 , {"flags" : []}, True , ["stream" , "private" ]),
1992
- (5179 , {"flags" : []}, False , ["private" ]),
1993
+ (5179 , {"flags" : ["mentioned" ]}, False , ["stream" , "private" ], None , None ),
1994
+ (
1995
+ 5179 ,
1996
+ {"flags" : ["wildcard_mentioned" ]},
1997
+ False ,
1998
+ ["stream" , "private" ],
1999
+ None ,
2000
+ None ,
2001
+ ),
2002
+ (5179 , {"flags" : []}, True , ["stream" , "private" ], None , None ),
2003
+ (5179 , {"flags" : []}, False , ["private" ], None , None ),
2004
+ (
2005
+ 5179 ,
2006
+ {"flags" : ["has_alert_word" ]},
2007
+ False ,
2008
+ ["stream" , "private" ],
2009
+ True ,
2010
+ True ,
2011
+ ),
2012
+ (
2013
+ 5179 ,
2014
+ {"flags" : ["has_alert_word" ]},
2015
+ False ,
2016
+ ["stream" , "private" ],
2017
+ True ,
2018
+ False ,
2019
+ ),
2020
+ (
2021
+ 5179 ,
2022
+ {"flags" : ["has_alert_word" ]},
2023
+ False ,
2024
+ ["stream" , "private" ],
2025
+ False ,
2026
+ True ,
2027
+ ),
2028
+ (
2029
+ 5179 ,
2030
+ {"flags" : ["has_alert_word" ]},
2031
+ False ,
2032
+ ["stream" , "private" ],
2033
+ False ,
2034
+ False ,
2035
+ ),
1993
2036
],
1994
2037
ids = [
1995
2038
"not_notified_since_self_message" ,
1996
2039
"notified_stream_and_private_since_directly_mentioned" ,
1997
2040
"notified_stream_and_private_since_wildcard_mentioned" ,
1998
2041
"notified_stream_since_stream_has_desktop_notifications" ,
1999
2042
"notified_private_since_private_message" ,
2043
+ "not_notified_for_stream_since_topic/stream_both_muted" ,
2044
+ "not_notified_for_stream_since_stream_muted" ,
2045
+ "not_notified_for_stream_since_topic_muted" ,
2046
+ "notified_for_stream_since_topic/stream_both_not_muted" ,
2000
2047
],
2001
2048
)
2002
2049
def test_notify_users_calling_msg_type (
@@ -2008,13 +2055,17 @@ def test_notify_users_calling_msg_type(
2008
2055
vary_each_msg ,
2009
2056
visual_notification_status ,
2010
2057
types_when_notify_called ,
2058
+ is_muted_stream : Optional [bool ],
2059
+ is_muted_topic : Optional [bool ],
2011
2060
):
2012
2061
message_fixture .update (vary_each_msg )
2013
2062
model .user_id = user_id
2014
2063
mocker .patch (
2015
2064
MODEL + ".is_visual_notifications_enabled" ,
2016
2065
return_value = visual_notification_status ,
2017
2066
)
2067
+ mocker .patch .object (model , "is_muted_stream" , return_value = is_muted_stream )
2068
+ mocker .patch .object (model , "is_muted_topic" , return_value = is_muted_topic )
2018
2069
notify = mocker .patch (MODULE + ".notify" )
2019
2070
2020
2071
model .notify_user (message_fixture )
@@ -2031,7 +2082,17 @@ def test_notify_users_calling_msg_type(
2031
2082
if target is not None :
2032
2083
title = f"Test Organization Name:\n Foo Foo (to { target } )"
2033
2084
# TODO: Test message content too?
2034
- notify .assert_called_once_with (title , mocker .ANY )
2085
+ if message_fixture ["type" ] == "private" :
2086
+ notify .assert_called_once_with (title , mocker .ANY )
2087
+ elif len (
2088
+ vary_each_msg ["flags" ]
2089
+ ) == 1 and "has_alert_word" in vary_each_msg .get ("flags" ):
2090
+ if not is_muted_topic and not is_muted_stream :
2091
+ notify .assert_called_once_with (title , mocker .ANY )
2092
+ else :
2093
+ notify .assert_not_called ()
2094
+ else :
2095
+ notify .assert_called_once_with (title , mocker .ANY )
2035
2096
else :
2036
2097
notify .assert_not_called ()
2037
2098
0 commit comments