summary refs log tree commit diff
path: root/tests/test_event_auth.py
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2018-08-24 11:44:26 -0400
committerGitHub <noreply@github.com>2018-08-24 11:44:26 -0400
commit83caead95a921b0977164468a52c5c0b6e9eee5a (patch)
treee87ae6c5d439de1e1dfd7598cab35a14e320ef59 /tests/test_event_auth.py
parentallow session_data to be any JSON instead of just a string (diff)
parentMerge pull request #3755 from matrix-org/erikj/fix_server_notice_tags (diff)
downloadsynapse-83caead95a921b0977164468a52c5c0b6e9eee5a.tar.xz
Merge branch 'develop' into e2e_backups
Diffstat (limited to 'tests/test_event_auth.py')
-rw-r--r--tests/test_event_auth.py98
1 files changed, 45 insertions, 53 deletions
diff --git a/tests/test_event_auth.py b/tests/test_event_auth.py
index 06112430e5..411b4a9f86 100644
--- a/tests/test_event_auth.py
+++ b/tests/test_event_auth.py
@@ -35,10 +35,7 @@ class EventAuthTestCase(unittest.TestCase):
         }
 
         # creator should be able to send state
-        event_auth.check(
-            _random_state_event(creator), auth_events,
-            do_sig_check=False,
-        )
+        event_auth.check(_random_state_event(creator), auth_events, do_sig_check=False)
 
         # joiner should not be able to send state
         self.assertRaises(
@@ -61,13 +58,9 @@ class EventAuthTestCase(unittest.TestCase):
         auth_events = {
             ("m.room.create", ""): _create_event(creator),
             ("m.room.member", creator): _join_event(creator),
-            ("m.room.power_levels", ""): _power_levels_event(creator, {
-                "state_default": "30",
-                "users": {
-                    pleb: "29",
-                    king: "30",
-                },
-            }),
+            ("m.room.power_levels", ""): _power_levels_event(
+                creator, {"state_default": "30", "users": {pleb: "29", king: "30"}}
+            ),
             ("m.room.member", pleb): _join_event(pleb),
             ("m.room.member", king): _join_event(king),
         }
@@ -82,10 +75,7 @@ class EventAuthTestCase(unittest.TestCase):
         ),
 
         # king should be able to send state
-        event_auth.check(
-            _random_state_event(king), auth_events,
-            do_sig_check=False,
-        )
+        event_auth.check(_random_state_event(king), auth_events, do_sig_check=False)
 
 
 # helpers for making events
@@ -94,52 +84,54 @@ TEST_ROOM_ID = "!test:room"
 
 
 def _create_event(user_id):
-    return FrozenEvent({
-        "room_id": TEST_ROOM_ID,
-        "event_id": _get_event_id(),
-        "type": "m.room.create",
-        "sender": user_id,
-        "content": {
-            "creator": user_id,
-        },
-    })
+    return FrozenEvent(
+        {
+            "room_id": TEST_ROOM_ID,
+            "event_id": _get_event_id(),
+            "type": "m.room.create",
+            "sender": user_id,
+            "content": {"creator": user_id},
+        }
+    )
 
 
 def _join_event(user_id):
-    return FrozenEvent({
-        "room_id": TEST_ROOM_ID,
-        "event_id": _get_event_id(),
-        "type": "m.room.member",
-        "sender": user_id,
-        "state_key": user_id,
-        "content": {
-            "membership": "join",
-        },
-    })
+    return FrozenEvent(
+        {
+            "room_id": TEST_ROOM_ID,
+            "event_id": _get_event_id(),
+            "type": "m.room.member",
+            "sender": user_id,
+            "state_key": user_id,
+            "content": {"membership": "join"},
+        }
+    )
 
 
 def _power_levels_event(sender, content):
-    return FrozenEvent({
-        "room_id": TEST_ROOM_ID,
-        "event_id": _get_event_id(),
-        "type": "m.room.power_levels",
-        "sender": sender,
-        "state_key": "",
-        "content": content,
-    })
+    return FrozenEvent(
+        {
+            "room_id": TEST_ROOM_ID,
+            "event_id": _get_event_id(),
+            "type": "m.room.power_levels",
+            "sender": sender,
+            "state_key": "",
+            "content": content,
+        }
+    )
 
 
 def _random_state_event(sender):
-    return FrozenEvent({
-        "room_id": TEST_ROOM_ID,
-        "event_id": _get_event_id(),
-        "type": "test.state",
-        "sender": sender,
-        "state_key": "",
-        "content": {
-            "membership": "join",
-        },
-    })
+    return FrozenEvent(
+        {
+            "room_id": TEST_ROOM_ID,
+            "event_id": _get_event_id(),
+            "type": "test.state",
+            "sender": sender,
+            "state_key": "",
+            "content": {"membership": "join"},
+        }
+    )
 
 
 event_count = 0
@@ -149,4 +141,4 @@ def _get_event_id():
     global event_count
     c = event_count
     event_count += 1
-    return "!%i:example.com" % (c, )
+    return "!%i:example.com" % (c,)