@@ -428,8 +428,21 @@ def test_contains_user_name(self) -> None:
428428 )
429429
430430 self .assertEqual (channel .code , 200 )
431- self .assertIn ("pattern" , channel .json_body )
432- self .assertEqual (channel .json_body ["pattern" ], username )
431+
432+ self .assertEqual (
433+ {
434+ "rule_id" : ".m.rule.contains_user_name" ,
435+ "default" : True ,
436+ "enabled" : True ,
437+ "pattern" : "bob" ,
438+ "actions" : [
439+ "notify" ,
440+ {"set_tweak" : "highlight" },
441+ {"set_tweak" : "sound" , "value" : "default" },
442+ ],
443+ },
444+ channel .json_body ,
445+ )
433446
434447 def test_is_user_mention (self ) -> None :
435448 """
@@ -445,7 +458,24 @@ def test_is_user_mention(self) -> None:
445458 )
446459
447460 self .assertEqual (channel .code , 200 )
448- self .assertIn ("conditions" , channel .json_body )
449- self .assertEqual (len (channel .json_body ["conditions" ]), 1 )
450- self .assertIn ("value" , channel .json_body ["conditions" ][0 ])
451- self .assertEqual (channel .json_body ["conditions" ][0 ]["value" ], user )
461+
462+ self .assertEqual (
463+ {
464+ "rule_id" : ".m.rule.is_user_mention" ,
465+ "default" : True ,
466+ "enabled" : True ,
467+ "conditions" : [
468+ {
469+ "kind" : "event_property_contains" ,
470+ "key" : "content.m\.mentions.user_ids" ,
471+ "value" : "@bob:test" ,
472+ }
473+ ],
474+ "actions" : [
475+ "notify" ,
476+ {"set_tweak" : "highlight" },
477+ {"set_tweak" : "sound" , "value" : "default" },
478+ ],
479+ },
480+ channel .json_body ,
481+ )
0 commit comments