diff options
author | Kegan Dougal <kegan@matrix.org> | 2016-11-22 09:59:27 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2016-11-22 09:59:27 +0000 |
commit | 0a8b0eeca17442a839d9f3a8624e331604b74711 (patch) | |
tree | 4e516a1408ed8cedfc6d368afb0d16940382c5ed /tests/events/test_utils.py | |
parent | Add remaining tests (diff) | |
download | synapse-0a8b0eeca17442a839d9f3a8624e331604b74711.tar.xz |
More tests
Diffstat (limited to '')
-rw-r--r-- | tests/events/test_utils.py | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/tests/events/test_utils.py b/tests/events/test_utils.py index d415e4cb3b..5b3326ce8d 100644 --- a/tests/events/test_utils.py +++ b/tests/events/test_utils.py @@ -123,7 +123,7 @@ class PruneEventTestCase(unittest.TestCase): class SerializeEventTestCase(unittest.TestCase): def serialize(self, ev, fields): - return serialize_event(ev, 1924354, event_fields=fields) + return serialize_event(ev, 1479807801915, only_event_fields=fields) def test_event_fields_works_with_keys(self): self.assertEquals( @@ -235,3 +235,58 @@ class SerializeEventTestCase(unittest.TestCase): ), {} ) + + def test_event_fields_nops_with_array_keys(self): + self.assertEquals( + self.serialize( + MockEvent( + sender="@alice:localhost", + room_id="!foo:bar", + content={ + "foo": ["I", "am", "an", "array"], + }, + ), + ["content.foo.1"] + ), + {} + ) + + def test_event_fields_all_fields_if_empty(self): + self.assertEquals( + self.serialize( + MockEvent( + room_id="!foo:bar", + content={ + "foo": "bar", + }, + ), + [] + ), + { + "room_id": "!foo:bar", + "content": { + "foo": "bar", + }, + "unsigned": {} + } + ) + + def test_event_fields_fail_if_fields_not_str(self): + self.assertEquals( + self.serialize( + MockEvent( + room_id="!foo:bar", + content={ + "foo": "bar", + }, + ), + ["room_id", 4] + ), + { + "room_id": "!foo:bar", + "content": { + "foo": "bar", + }, + "unsigned": {} + } + ) |