Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1e73b59

Browse files
committed
Lint
1 parent 726f13e commit 1e73b59

File tree

2 files changed

+58
-12
lines changed

2 files changed

+58
-12
lines changed

synapse/rulecheck/domain_rule_checker.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ async def user_may_send_3pid_invite(
144144
) -> bool:
145145
"""Implements the user_may_send_3pid_invite spam checker callback."""
146146
return await self._user_may_invite(
147-
room_id=room_id, inviter_userid=inviter_userid, invitee_userid=None,
147+
room_id=room_id,
148+
inviter_userid=inviter_userid,
149+
invitee_userid=None,
148150
)
149151

150152
async def _user_may_invite(
@@ -186,7 +188,7 @@ async def _user_may_invite(
186188
await self._api.public_room_list_manager.room_is_in_public_room_list(
187189
room_id
188190
)
189-
)
191+
)
190192

191193
if (
192194
published_room

tests/rulecheck/test_domainrulecheck.py

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class MockEvent:
3333
"""Mock of an event, only implementing the fields the DomainRuleChecker module will
3434
use.
3535
"""
36+
3637
sender: str
3738
membership: Optional[str] = None
3839

@@ -42,6 +43,7 @@ class MockPublicRoomListManager:
4243
"""Mock of a synapse.module_api.PublicRoomListManager, only implementing the method
4344
the DomainRuleChecker module will use.
4445
"""
46+
4547
_published: bool
4648

4749
async def room_is_in_public_room_list(self, room_id: str) -> bool:
@@ -53,6 +55,7 @@ class MockModuleApi:
5355
"""Mock of a synapse.module_api.ModuleApi, only implementing the methods the
5456
DomainRuleChecker module will use.
5557
"""
58+
5659
_new_room: bool
5760
_published: bool
5861

@@ -89,7 +92,12 @@ async def get_room_state(self, *args, **kwargs):
8992
# reactor to run asynchronous code.
9093
class DomainRuleCheckerTestCase(unittest.HomeserverTestCase):
9194
def _test_user_may_invite(
92-
self, config, inviter, invitee, new_room, published,
95+
self,
96+
config,
97+
inviter,
98+
invitee,
99+
new_room,
100+
published,
93101
) -> bool:
94102
check = DomainRuleChecker(config, MockModuleApi(new_room, published))
95103
return self.get_success(check.user_may_invite(inviter, invitee, "room"))
@@ -106,33 +114,53 @@ def test_allowed(self):
106114

107115
self.assertTrue(
108116
self._test_user_may_invite(
109-
config, "test:source_one", "test:target_one", False, False,
117+
config,
118+
"test:source_one",
119+
"test:target_one",
120+
False,
121+
False,
110122
),
111123
)
112124

113125
self.assertTrue(
114126
self._test_user_may_invite(
115-
config, "test:source_one", "test:target_two", False, False,
127+
config,
128+
"test:source_one",
129+
"test:target_two",
130+
False,
131+
False,
116132
),
117133
)
118134

119135
self.assertTrue(
120136
self._test_user_may_invite(
121-
config, "test:source_two", "test:target_two", False, False,
137+
config,
138+
"test:source_two",
139+
"test:target_two",
140+
False,
141+
False,
122142
),
123143
)
124144

125145
# User can invite internal user to a published room
126146
self.assertTrue(
127147
self._test_user_may_invite(
128-
config, "test:source_one", "test1:target_one", False, True,
148+
config,
149+
"test:source_one",
150+
"test1:target_one",
151+
False,
152+
True,
129153
),
130154
)
131155

132156
# User can invite external user to a non-published room
133157
self.assertTrue(
134158
self._test_user_may_invite(
135-
config, "test:source_one", "test:target_two", False, False,
159+
config,
160+
"test:source_one",
161+
"test:target_two",
162+
False,
163+
False,
136164
),
137165
)
138166

@@ -148,12 +176,20 @@ def test_disallowed(self):
148176

149177
self.assertFalse(
150178
self._test_user_may_invite(
151-
config, "test:source_one", "test:target_three", False, False,
179+
config,
180+
"test:source_one",
181+
"test:target_three",
182+
False,
183+
False,
152184
)
153185
)
154186
self.assertFalse(
155187
self._test_user_may_invite(
156-
config, "test:source_two", "test:target_three", False, False,
188+
config,
189+
"test:source_two",
190+
"test:target_three",
191+
False,
192+
False,
157193
)
158194
)
159195
self.assertFalse(
@@ -185,7 +221,11 @@ def test_default_allow(self):
185221

186222
self.assertTrue(
187223
self._test_user_may_invite(
188-
config, "test:source_three", "test:target_one", False, False,
224+
config,
225+
"test:source_three",
226+
"test:target_one",
227+
False,
228+
False,
189229
)
190230
)
191231

@@ -200,7 +240,11 @@ def test_default_deny(self):
200240

201241
self.assertFalse(
202242
self._test_user_may_invite(
203-
config, "test:source_three", "test:target_one", False, False,
243+
config,
244+
"test:source_three",
245+
"test:target_one",
246+
False,
247+
False,
204248
)
205249
)
206250

0 commit comments

Comments
 (0)