Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit a7b78ca

Browse files
committed
Match against the full condition from the spec
1 parent 986ac83 commit a7b78ca

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

tests/rest/client/test_push_rule_attrs.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)