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

Commit

Permalink
Match against the full condition from the spec
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Jun 16, 2023
1 parent 986ac83 commit a7b78ca
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions tests/rest/client/test_push_rule_attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,21 @@ def test_contains_user_name(self) -> None:
)

self.assertEqual(channel.code, 200)
self.assertIn("pattern", channel.json_body)
self.assertEqual(channel.json_body["pattern"], username)

self.assertEqual(
{
"rule_id": ".m.rule.contains_user_name",
"default": True,
"enabled": True,
"pattern": "bob",
"actions": [
"notify",
{"set_tweak": "highlight"},
{"set_tweak": "sound", "value": "default"},
],
},
channel.json_body,
)

def test_is_user_mention(self) -> None:
"""
Expand All @@ -445,7 +458,24 @@ def test_is_user_mention(self) -> None:
)

self.assertEqual(channel.code, 200)
self.assertIn("conditions", channel.json_body)
self.assertEqual(len(channel.json_body["conditions"]), 1)
self.assertIn("value", channel.json_body["conditions"][0])
self.assertEqual(channel.json_body["conditions"][0]["value"], user)

self.assertEqual(
{
"rule_id": ".m.rule.is_user_mention",
"default": True,
"enabled": True,
"conditions": [
{
"kind": "event_property_contains",
"key": "content.m\.mentions.user_ids",
"value": "@bob:test",
}
],
"actions": [
"notify",
{"set_tweak": "highlight"},
{"set_tweak": "sound", "value": "default"},
],
},
channel.json_body,
)

0 comments on commit a7b78ca

Please sign in to comment.