This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Remove setattr with kwargs from HomeServer class 2: Electric bungaloo #8515
Merged
clokep
merged 3 commits into
matrix-org:develop
from
ShadowJonathan:fix/homeserver_kwargs
Oct 15, 2020
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Apply some internal fixes to the `HomeServer` class to make its code more idiomatic and statically-verifiable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
import uuid | ||
import warnings | ||
from inspect import getcallargs | ||
from typing import Type | ||
from urllib import parse as urlparse | ||
|
||
from mock import Mock, patch | ||
|
@@ -194,8 +195,8 @@ def setup_test_homeserver( | |
name="test", | ||
config=None, | ||
reactor=None, | ||
homeserverToUse=TestHomeServer, | ||
**kargs | ||
homeserver_to_use: Type[HomeServer] = TestHomeServer, | ||
**kwargs | ||
): | ||
""" | ||
Setup a homeserver suitable for running tests against. Keyword arguments | ||
|
@@ -218,8 +219,8 @@ def setup_test_homeserver( | |
|
||
config.ldap_enabled = False | ||
|
||
if "clock" not in kargs: | ||
kargs["clock"] = MockClock() | ||
if "clock" not in kwargs: | ||
kwargs["clock"] = MockClock() | ||
|
||
if USE_POSTGRES_FOR_TESTS: | ||
test_db = "synapse_test_%s" % uuid.uuid4().hex | ||
|
@@ -264,18 +265,20 @@ def setup_test_homeserver( | |
cur.close() | ||
db_conn.close() | ||
|
||
hs = homeserverToUse( | ||
name, | ||
config=config, | ||
version_string="Synapse/tests", | ||
tls_server_context_factory=Mock(), | ||
tls_client_options_factory=Mock(), | ||
reactor=reactor, | ||
**kargs | ||
hs = homeserver_to_use( | ||
name, config=config, version_string="Synapse/tests", reactor=reactor, | ||
) | ||
|
||
# Install @cache_in_self attributes | ||
for key, val in kwargs.items(): | ||
setattr(hs, key, val) | ||
|
||
# Mock TLS | ||
hs.tls_server_context_factory = Mock() | ||
hs.tls_client_options_factory = Mock() | ||
Comment on lines
+277
to
+278
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if these are used anywhere...? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess remove them and see which tests fail? |
||
|
||
hs.setup() | ||
if homeserverToUse.__name__ == "TestHomeServer": | ||
if homeserver_to_use == TestHomeServer: | ||
hs.setup_background_tasks() | ||
|
||
if isinstance(db_engine, PostgresEngine): | ||
|
@@ -339,7 +342,7 @@ async def validate_hash(p, h): | |
|
||
hs.get_auth_handler().validate_hash = validate_hash | ||
|
||
fed = kargs.get("resource_for_federation", None) | ||
fed = kwargs.get("resource_for_federation", None) | ||
if fed: | ||
register_federation_servlets(hs, fed) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.