diff options
author | Kegan Dougal <kegan@matrix.org> | 2015-01-29 14:28:34 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2015-01-29 14:28:34 +0000 |
commit | 38b27bd2cbf38141938d6170c41e1d1dac9928cd (patch) | |
tree | dcb7efef4963edc90c837392174e1dff416a2cfe /tests/api | |
parent | Add basic filtering public API unit tests. Use defers in the right places. (diff) | |
download | synapse-38b27bd2cbf38141938d6170c41e1d1dac9928cd.tar.xz |
Add filter_room_state unit tests.
Diffstat (limited to 'tests/api')
-rw-r--r-- | tests/api/test_filtering.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/api/test_filtering.py b/tests/api/test_filtering.py index 97fb9758e9..aa93616a9f 100644 --- a/tests/api/test_filtering.py +++ b/tests/api/test_filtering.py @@ -405,6 +405,62 @@ class FilteringTestCase(unittest.TestCase): self.assertEquals([], results) @defer.inlineCallbacks + def test_filter_room_state_match(self): + user_filter = { + "room": { + "state": { + "types": ["m.*"] + } + } + } + user = UserID.from_string("@" + user_localpart + ":test") + filter_id = yield self.datastore.add_user_filter( + user_localpart=user_localpart, + user_filter=user_filter, + ) + event = MockEvent( + sender="@foo:bar", + type="m.room.topic", + room_id="!foo:bar" + ) + events = [event] + + results = yield self.filtering.filter_room_state( + events=events, + user=user, + filter_id=filter_id + ) + self.assertEquals(events, results) + + @defer.inlineCallbacks + def test_filter_room_state_no_match(self): + user_filter = { + "room": { + "state": { + "types": ["m.*"] + } + } + } + user = UserID.from_string("@" + user_localpart + ":test") + filter_id = yield self.datastore.add_user_filter( + user_localpart=user_localpart, + user_filter=user_filter, + ) + event = MockEvent( + sender="@foo:bar", + type="org.matrix.custom.event", + room_id="!foo:bar" + ) + events = [event] + + results = yield self.filtering.filter_room_state( + events=events, + user=user, + filter_id=filter_id + ) + self.assertEquals([], results) + + @defer.inlineCallbacks def test_add_filter(self): user_filter = { "room": { |