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

Commit

Permalink
Add tests for new code path
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Mar 29, 2022
1 parent 239ba27 commit 198ee1f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/federation/test_federation_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from typing import Optional
from unittest.mock import Mock

from parameterized import parameterized_class
from signedjson import key, sign
from signedjson.types import BaseKey, SigningKey

Expand Down Expand Up @@ -154,6 +155,12 @@ def test_send_receipts_with_backoff(self):
)


@parameterized_class(
[
{"enable_room_poke_code_path": False},
{"enable_room_poke_code_path": True},
]
)
class FederationSenderDevicesTestCases(HomeserverTestCase):
servlets = [
admin.register_servlets,
Expand All @@ -168,6 +175,7 @@ def make_homeserver(self, reactor, clock):
def default_config(self):
c = super().default_config()
c["send_federation"] = True
c["use_new_device_lists_changes_in_room"] = self.enable_room_poke_code_path
return c

def prepare(self, reactor, clock, hs):
Expand All @@ -180,6 +188,16 @@ def get_users_who_share_room_with_user(user_id):
get_users_who_share_room_with_user
)

def get_rooms_for_user(user_id):
return defer.succeed({"!room:host1"})

hs.get_datastores().main.get_rooms_for_user = get_rooms_for_user

def get_users_in_room(room_id):
return defer.succeed({"@user2:host2"})

hs.get_datastores().main.get_users_in_room = get_users_in_room

# whenever send_transaction is called, record the edu data
self.edus = []
self.hs.get_federation_transport_client().send_transaction.side_effect = (
Expand Down

0 comments on commit 198ee1f

Please sign in to comment.