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

Commit

Permalink
Fix-up tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Oct 6, 2022
1 parent ea41d8b commit 7db5fc6
Showing 1 changed file with 1 addition and 73 deletions.
74 changes: 1 addition & 73 deletions tests/push/test_push_rule_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@


class PushRuleEvaluatorTestCase(unittest.TestCase):
def _get_evaluator(
self,
content: JsonDict,
relations: Optional[Dict[str, Set[Tuple[str, str]]]] = None,
relations_match_enabled: bool = False,
) -> PushRuleEvaluator:
def _get_evaluator(self, content: JsonDict) -> PushRuleEvaluator:
event = FrozenEvent(
{
"event_id": "$event_id",
Expand All @@ -63,8 +58,6 @@ def _get_evaluator(
room_member_count,
sender_power_level,
power_levels.get("notifications", {}),
relations or {},
relations_match_enabled,
)

def test_display_name(self) -> None:
Expand Down Expand Up @@ -299,71 +292,6 @@ def test_tweaks_for_actions(self) -> None:
{"sound": "default", "highlight": True},
)

def test_relation_match(self) -> None:
"""Test the relation_match push rule kind."""

# Check if the experimental feature is disabled.
evaluator = self._get_evaluator(
{}, {"m.annotation": {("@user:test", "m.reaction")}}
)

# A push rule evaluator with the experimental rule enabled.
evaluator = self._get_evaluator(
{}, {"m.annotation": {("@user:test", "m.reaction")}}, True
)

# Check just relation type.
condition = {
"kind": "org.matrix.msc3772.relation_match",
"rel_type": "m.annotation",
}
self.assertTrue(evaluator.matches(condition, "@user:test", "foo"))

# Check relation type and sender.
condition = {
"kind": "org.matrix.msc3772.relation_match",
"rel_type": "m.annotation",
"sender": "@user:test",
}
self.assertTrue(evaluator.matches(condition, "@user:test", "foo"))
condition = {
"kind": "org.matrix.msc3772.relation_match",
"rel_type": "m.annotation",
"sender": "@other:test",
}
self.assertFalse(evaluator.matches(condition, "@user:test", "foo"))

# Check relation type and event type.
condition = {
"kind": "org.matrix.msc3772.relation_match",
"rel_type": "m.annotation",
"type": "m.reaction",
}
self.assertTrue(evaluator.matches(condition, "@user:test", "foo"))

# Check just sender, this fails since rel_type is required.
condition = {
"kind": "org.matrix.msc3772.relation_match",
"sender": "@user:test",
}
self.assertFalse(evaluator.matches(condition, "@user:test", "foo"))

# Check sender glob.
condition = {
"kind": "org.matrix.msc3772.relation_match",
"rel_type": "m.annotation",
"sender": "@*:test",
}
self.assertTrue(evaluator.matches(condition, "@user:test", "foo"))

# Check event type glob.
condition = {
"kind": "org.matrix.msc3772.relation_match",
"rel_type": "m.annotation",
"event_type": "*.reaction",
}
self.assertTrue(evaluator.matches(condition, "@user:test", "foo"))


class TestBulkPushRuleEvaluator(unittest.HomeserverTestCase):
"""Tests for the bulk push rule evaluator"""
Expand Down

0 comments on commit 7db5fc6

Please sign in to comment.