diff options
author | Kegan Dougal <kegan@matrix.org> | 2016-11-21 17:52:45 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2016-11-21 17:52:45 +0000 |
commit | 70a2157b6458369b374cceeb0e5c8b0d985c6946 (patch) | |
tree | 3994e3d3b70069f3d887153a2eb4dfe011838ddf /tests/events/test_utils.py | |
parent | Move event_fields filtering to serialize_event (diff) | |
download | synapse-70a2157b6458369b374cceeb0e5c8b0d985c6946.tar.xz |
Start adding some tests
Diffstat (limited to '')
-rw-r--r-- | tests/events/test_utils.py | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/tests/events/test_utils.py b/tests/events/test_utils.py index b9f55d174d..7136cca7c2 100644 --- a/tests/events/test_utils.py +++ b/tests/events/test_utils.py @@ -17,7 +17,11 @@ from .. import unittest from synapse.events import FrozenEvent -from synapse.events.utils import prune_event +from synapse.events.utils import prune_event, serialize_event + + +def MockEvent(**kwargs): + return FrozenEvent(kwargs) class PruneEventTestCase(unittest.TestCase): @@ -118,11 +122,41 @@ class PruneEventTestCase(unittest.TestCase): class SerializeEventTestCase(unittest.TestCase): + def serialize(self, ev, fields): + return serialize_event(ev, 1924354, event_fields=fields) + def test_event_fields_works_with_keys(self): - pass + self.assertEquals( + self.serialize( + MockEvent( + sender="@alice:localhost", + room_id="!foo:bar" + ), + ["room_id"] + ), + { + "room_id": "!foo:bar", + } + ) def test_event_fields_works_with_nested_keys(self): - pass + self.assertEquals( + self.serialize( + MockEvent( + sender="@alice:localhost", + room_id="!foo:bar", + content={ + "body": "A message", + }, + ), + ["content.body"] + ), + { + "content": { + "body": "A message", + } + } + ) def test_event_fields_works_with_dot_keys(self): pass |