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

Fix unawaited coroutine error in tests. #8072

Merged
merged 2 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8072.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Convert various parts of the codebase to async/await.
30 changes: 20 additions & 10 deletions tests/federation/test_complexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ def test_join_too_large(self):
fed_transport = self.hs.get_federation_transport_client()

# Mock out some things, because we don't want to test the whole join
fed_transport.client.get_json = Mock(return_value=make_awaitable({"v1": 9999}))
fed_transport.client.get_json = Mock(
side_effect=lambda *args, **kwargs: make_awaitable({"v1": 9999})
)
handler.federation_handler.do_invite_join = Mock(
return_value=make_awaitable(("", 1))
side_effect=lambda *args, **kwargs: make_awaitable(("", 1))
)

d = handler._remote_join(
Expand Down Expand Up @@ -110,9 +112,11 @@ def test_join_too_large_admin(self):
fed_transport = self.hs.get_federation_transport_client()

# Mock out some things, because we don't want to test the whole join
fed_transport.client.get_json = Mock(return_value=make_awaitable({"v1": 9999}))
fed_transport.client.get_json = Mock(
side_effect=lambda *args, **kwargs: make_awaitable({"v1": 9999})
)
handler.federation_handler.do_invite_join = Mock(
return_value=make_awaitable(("", 1))
side_effect=lambda *args, **kwargs: make_awaitable(("", 1))
)

d = handler._remote_join(
Expand Down Expand Up @@ -148,9 +152,11 @@ def test_join_too_large_once_joined(self):
fed_transport = self.hs.get_federation_transport_client()

# Mock out some things, because we don't want to test the whole join
fed_transport.client.get_json = Mock(return_value=make_awaitable(None))
fed_transport.client.get_json = Mock(
side_effect=lambda *args, **kwargs: make_awaitable(None)
)
handler.federation_handler.do_invite_join = Mock(
return_value=make_awaitable(("", 1))
side_effect=lambda *args, **kwargs: make_awaitable(("", 1))
)

# Artificially raise the complexity
Expand Down Expand Up @@ -204,9 +210,11 @@ def test_join_too_large_no_admin(self):
fed_transport = self.hs.get_federation_transport_client()

# Mock out some things, because we don't want to test the whole join
fed_transport.client.get_json = Mock(return_value=make_awaitable({"v1": 9999}))
fed_transport.client.get_json = Mock(
side_effect=lambda *args, **kwargs: make_awaitable({"v1": 9999})
)
handler.federation_handler.do_invite_join = Mock(
return_value=make_awaitable(("", 1))
side_effect=lambda *args, **kwargs: make_awaitable(("", 1))
)

d = handler._remote_join(
Expand Down Expand Up @@ -234,9 +242,11 @@ def test_join_too_large_admin(self):
fed_transport = self.hs.get_federation_transport_client()

# Mock out some things, because we don't want to test the whole join
fed_transport.client.get_json = Mock(return_value=make_awaitable({"v1": 9999}))
fed_transport.client.get_json = Mock(
side_effect=lambda *args, **kwargs: make_awaitable({"v1": 9999})
)
handler.federation_handler.do_invite_join = Mock(
return_value=make_awaitable(("", 1))
side_effect=lambda *args, **kwargs: make_awaitable(("", 1))
)

d = handler._remote_join(
Expand Down