summary refs log tree commit diff
path: root/tests/rest/client/v1
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2019-05-10 00:12:11 -0500
committerGitHub <noreply@github.com>2019-05-10 00:12:11 -0500
commitb36c82576e3bb7ea72600ecf0e80c904ccf47d1d (patch)
tree18a43cb8a47a0c5400ad93c1617bdd16de8753e7 /tests/rest/client/v1
parentAdd AllowEncodedSlashes to apache (#5068) (diff)
downloadsynapse-b36c82576e3bb7ea72600ecf0e80c904ccf47d1d.tar.xz
Run Black on the tests again (#5170)
Diffstat (limited to 'tests/rest/client/v1')
-rw-r--r--tests/rest/client/v1/test_directory.py53
-rw-r--r--tests/rest/client/v1/test_login.py36
-rw-r--r--tests/rest/client/v1/test_profile.py27
3 files changed, 32 insertions, 84 deletions
diff --git a/tests/rest/client/v1/test_directory.py b/tests/rest/client/v1/test_directory.py
index f63c68e7ed..73c5b44b46 100644
--- a/tests/rest/client/v1/test_directory.py
+++ b/tests/rest/client/v1/test_directory.py
@@ -45,7 +45,7 @@ class DirectoryTestCase(unittest.HomeserverTestCase):
         self.room_owner_tok = self.login("room_owner", "test")
 
         self.room_id = self.helper.create_room_as(
-            self.room_owner, tok=self.room_owner_tok,
+            self.room_owner, tok=self.room_owner_tok
         )
 
         self.user = self.register_user("user", "test")
@@ -80,12 +80,10 @@ class DirectoryTestCase(unittest.HomeserverTestCase):
 
         # We use deliberately a localpart under the length threshold so
         # that we can make sure that the check is done on the whole alias.
-        data = {
-            "room_alias_name": random_string(256 - len(self.hs.hostname)),
-        }
+        data = {"room_alias_name": random_string(256 - len(self.hs.hostname))}
         request_data = json.dumps(data)
         request, channel = self.make_request(
-            "POST", url, request_data, access_token=self.user_tok,
+            "POST", url, request_data, access_token=self.user_tok
         )
         self.render(request)
         self.assertEqual(channel.code, 400, channel.result)
@@ -96,51 +94,42 @@ class DirectoryTestCase(unittest.HomeserverTestCase):
         # Check with an alias of allowed length. There should already be
         # a test that ensures it works in test_register.py, but let's be
         # as cautious as possible here.
-        data = {
-            "room_alias_name": random_string(5),
-        }
+        data = {"room_alias_name": random_string(5)}
         request_data = json.dumps(data)
         request, channel = self.make_request(
-            "POST", url, request_data, access_token=self.user_tok,
+            "POST", url, request_data, access_token=self.user_tok
         )
         self.render(request)
         self.assertEqual(channel.code, 200, channel.result)
 
     def set_alias_via_state_event(self, expected_code, alias_length=5):
-        url = ("/_matrix/client/r0/rooms/%s/state/m.room.aliases/%s"
-               % (self.room_id, self.hs.hostname))
-
-        data = {
-            "aliases": [
-                self.random_alias(alias_length),
-            ],
-        }
+        url = "/_matrix/client/r0/rooms/%s/state/m.room.aliases/%s" % (
+            self.room_id,
+            self.hs.hostname,
+        )
+
+        data = {"aliases": [self.random_alias(alias_length)]}
         request_data = json.dumps(data)
 
         request, channel = self.make_request(
-            "PUT", url, request_data, access_token=self.user_tok,
+            "PUT", url, request_data, access_token=self.user_tok
         )
         self.render(request)
         self.assertEqual(channel.code, expected_code, channel.result)
 
     def set_alias_via_directory(self, expected_code, alias_length=5):
         url = "/_matrix/client/r0/directory/room/%s" % self.random_alias(alias_length)
-        data = {
-            "room_id": self.room_id,
-        }
+        data = {"room_id": self.room_id}
         request_data = json.dumps(data)
 
         request, channel = self.make_request(
-            "PUT", url, request_data, access_token=self.user_tok,
+            "PUT", url, request_data, access_token=self.user_tok
         )
         self.render(request)
         self.assertEqual(channel.code, expected_code, channel.result)
 
     def random_alias(self, length):
-        return RoomAlias(
-            random_string(length),
-            self.hs.hostname,
-        ).to_string()
+        return RoomAlias(random_string(length), self.hs.hostname).to_string()
 
     def ensure_user_left_room(self):
         self.ensure_membership("leave")
@@ -151,17 +140,9 @@ class DirectoryTestCase(unittest.HomeserverTestCase):
     def ensure_membership(self, membership):
         try:
             if membership == "leave":
-                self.helper.leave(
-                    room=self.room_id,
-                    user=self.user,
-                    tok=self.user_tok,
-                )
+                self.helper.leave(room=self.room_id, user=self.user, tok=self.user_tok)
             if membership == "join":
-                self.helper.join(
-                    room=self.room_id,
-                    user=self.user,
-                    tok=self.user_tok,
-                )
+                self.helper.join(room=self.room_id, user=self.user, tok=self.user_tok)
         except AssertionError:
             # We don't care whether the leave request didn't return a 200 (e.g.
             # if the user isn't already in the room), because we only want to
diff --git a/tests/rest/client/v1/test_login.py b/tests/rest/client/v1/test_login.py
index 9ebd91f678..0397f91a9e 100644
--- a/tests/rest/client/v1/test_login.py
+++ b/tests/rest/client/v1/test_login.py
@@ -37,10 +37,7 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
         for i in range(0, 6):
             params = {
                 "type": "m.login.password",
-                "identifier": {
-                    "type": "m.id.user",
-                    "user": "kermit" + str(i),
-                },
+                "identifier": {"type": "m.id.user", "user": "kermit" + str(i)},
                 "password": "monkey",
             }
             request_data = json.dumps(params)
@@ -57,14 +54,11 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
         # than 1min.
         self.assertTrue(retry_after_ms < 6000)
 
-        self.reactor.advance(retry_after_ms / 1000.)
+        self.reactor.advance(retry_after_ms / 1000.0)
 
         params = {
             "type": "m.login.password",
-            "identifier": {
-                "type": "m.id.user",
-                "user": "kermit" + str(i),
-            },
+            "identifier": {"type": "m.id.user", "user": "kermit" + str(i)},
             "password": "monkey",
         }
         request_data = json.dumps(params)
@@ -82,10 +76,7 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
         for i in range(0, 6):
             params = {
                 "type": "m.login.password",
-                "identifier": {
-                    "type": "m.id.user",
-                    "user": "kermit",
-                },
+                "identifier": {"type": "m.id.user", "user": "kermit"},
                 "password": "monkey",
             }
             request_data = json.dumps(params)
@@ -102,14 +93,11 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
         # than 1min.
         self.assertTrue(retry_after_ms < 6000)
 
-        self.reactor.advance(retry_after_ms / 1000.)
+        self.reactor.advance(retry_after_ms / 1000.0)
 
         params = {
             "type": "m.login.password",
-            "identifier": {
-                "type": "m.id.user",
-                "user": "kermit",
-            },
+            "identifier": {"type": "m.id.user", "user": "kermit"},
             "password": "monkey",
         }
         request_data = json.dumps(params)
@@ -127,10 +115,7 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
         for i in range(0, 6):
             params = {
                 "type": "m.login.password",
-                "identifier": {
-                    "type": "m.id.user",
-                    "user": "kermit",
-                },
+                "identifier": {"type": "m.id.user", "user": "kermit"},
                 "password": "notamonkey",
             }
             request_data = json.dumps(params)
@@ -147,14 +132,11 @@ class LoginRestServletTestCase(unittest.HomeserverTestCase):
         # than 1min.
         self.assertTrue(retry_after_ms < 6000)
 
-        self.reactor.advance(retry_after_ms / 1000.)
+        self.reactor.advance(retry_after_ms / 1000.0)
 
         params = {
             "type": "m.login.password",
-            "identifier": {
-                "type": "m.id.user",
-                "user": "kermit",
-            },
+            "identifier": {"type": "m.id.user", "user": "kermit"},
             "password": "notamonkey",
         }
         request_data = json.dumps(params)
diff --git a/tests/rest/client/v1/test_profile.py b/tests/rest/client/v1/test_profile.py
index 7306e61b7c..ed034879cf 100644
--- a/tests/rest/client/v1/test_profile.py
+++ b/tests/rest/client/v1/test_profile.py
@@ -199,37 +199,24 @@ class ProfilesRestrictedTestCase(unittest.HomeserverTestCase):
     def test_in_shared_room(self):
         self.ensure_requester_left_room()
 
-        self.helper.join(
-            room=self.room_id,
-            user=self.requester,
-            tok=self.requester_tok,
-        )
+        self.helper.join(room=self.room_id, user=self.requester, tok=self.requester_tok)
 
         self.try_fetch_profile(200, self.requester_tok)
 
     def try_fetch_profile(self, expected_code, access_token=None):
-        self.request_profile(
-            expected_code,
-            access_token=access_token
-        )
+        self.request_profile(expected_code, access_token=access_token)
 
         self.request_profile(
-            expected_code,
-            url_suffix="/displayname",
-            access_token=access_token,
+            expected_code, url_suffix="/displayname", access_token=access_token
         )
 
         self.request_profile(
-            expected_code,
-            url_suffix="/avatar_url",
-            access_token=access_token,
+            expected_code, url_suffix="/avatar_url", access_token=access_token
         )
 
     def request_profile(self, expected_code, url_suffix="", access_token=None):
         request, channel = self.make_request(
-            "GET",
-            self.profile_url + url_suffix,
-            access_token=access_token,
+            "GET", self.profile_url + url_suffix, access_token=access_token
         )
         self.render(request)
         self.assertEqual(channel.code, expected_code, channel.result)
@@ -237,9 +224,7 @@ class ProfilesRestrictedTestCase(unittest.HomeserverTestCase):
     def ensure_requester_left_room(self):
         try:
             self.helper.leave(
-                room=self.room_id,
-                user=self.requester,
-                tok=self.requester_tok,
+                room=self.room_id, user=self.requester, tok=self.requester_tok
             )
         except AssertionError:
             # We don't care whether the leave request didn't return a 200 (e.g.