summary refs log tree commit diff
path: root/tests/events/test_utils.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/events/test_utils.py57
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": {}
+            }
+        )