summary refs log tree commit diff
path: root/tests/push
diff options
context:
space:
mode:
authorreivilibre <38398653+reivilibre@users.noreply.github.com>2020-07-06 11:43:41 +0100
committerGitHub <noreply@github.com>2020-07-06 11:43:41 +0100
commit57feeab364325374b14ff67ac97c288983cc5cde (patch)
tree4a66d0b7c2be8228857a7be9e2c0dcd0eb603100 /tests/push
parentAllow to use higher versions of prometheus_client (#7780) (diff)
downloadsynapse-57feeab364325374b14ff67ac97c288983cc5cde.tar.xz
Don't ignore `set_tweak` actions with no explicit `value`. (#7766)
* Fix spec compliance; tweaks without values are valid

(default to True, which is only concretely specified for
`highlight`, but it seems only reasonable to generalise)

* Changelog for 7766.

* Add documentation to `tweaks_for_actions`

May as well tidy up when I'm here.

* Add a test for `tweaks_for_actions`
Diffstat (limited to 'tests/push')
-rw-r--r--tests/push/test_push_rule_evaluator.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/push/test_push_rule_evaluator.py b/tests/push/test_push_rule_evaluator.py

index af35d23aea..1f4b5ca2ac 100644 --- a/tests/push/test_push_rule_evaluator.py +++ b/tests/push/test_push_rule_evaluator.py
@@ -15,6 +15,7 @@ from synapse.api.room_versions import RoomVersions from synapse.events import FrozenEvent +from synapse.push import push_rule_evaluator from synapse.push.push_rule_evaluator import PushRuleEvaluatorForEvent from tests import unittest @@ -84,3 +85,19 @@ class PushRuleEvaluatorTestCase(unittest.TestCase): for body in (1, True, {"foo": "bar"}): evaluator = self._get_evaluator({"body": body}) self.assertFalse(evaluator.matches(condition, "@user:test", "foo")) + + def test_tweaks_for_actions(self): + """ + This tests the behaviour of tweaks_for_actions. + """ + + actions = [ + {"set_tweak": "sound", "value": "default"}, + {"set_tweak": "highlight"}, + "notify", + ] + + self.assertEqual( + push_rule_evaluator.tweaks_for_actions(actions), + {"sound": "default", "highlight": True}, + )