当前位置: 首页>>代码示例>>Python>>正文


Python HomeServer.get_replication_layer方法代码示例

本文整理汇总了Python中synapse.server.HomeServer.get_replication_layer方法的典型用法代码示例。如果您正苦于以下问题:Python HomeServer.get_replication_layer方法的具体用法?Python HomeServer.get_replication_layer怎么用?Python HomeServer.get_replication_layer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在synapse.server.HomeServer的用法示例。


在下文中一共展示了HomeServer.get_replication_layer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import get_replication_layer [as 别名]
    def setUp(self):
        hs = HomeServer("test",
                clock=MockClock(),
                db_pool=None,
                datastore=Mock(spec=[
                    "set_presence_state",
                    "is_presence_visible",

                    "set_profile_displayname",

                    "get_rooms_for_user_where_membership_is",
                ]),
                handlers=None,
                resource_for_federation=Mock(),
                http_client=None,
                replication_layer=MockReplication(),
            )
        hs.handlers = PresenceAndProfileHandlers(hs)

        self.datastore = hs.get_datastore()

        self.replication = hs.get_replication_layer()
        self.replication.send_edu = Mock()

        def send_edu(*args, **kwargs):
            # print "send_edu: %s, %s" % (args, kwargs)
            return defer.succeed((200, "OK"))
        self.replication.send_edu.side_effect = send_edu

        def get_profile_displayname(user_localpart):
            return defer.succeed("Frank")
        self.datastore.get_profile_displayname = get_profile_displayname

        def is_presence_visible(*args, **kwargs):
            return defer.succeed(False)
        self.datastore.is_presence_visible = is_presence_visible

        def get_profile_avatar_url(user_localpart):
            return defer.succeed("http://foo")
        self.datastore.get_profile_avatar_url = get_profile_avatar_url

        self.presence_list = [
            {"observed_user_id": "@banana:test"},
            {"observed_user_id": "@clementine:test"},
        ]
        def get_presence_list(user_localpart, accepted=None):
            return defer.succeed(self.presence_list)
        self.datastore.get_presence_list = get_presence_list

        def user_rooms_intersect(userlist):
            return defer.succeed(False)
        self.datastore.user_rooms_intersect = user_rooms_intersect

        self.handlers = hs.get_handlers()

        self.mock_update_client = Mock()
        def update(*args, **kwargs):
            # print "mock_update_client: %s, %s" %(args, kwargs)
            return defer.succeed(None)
        self.mock_update_client.side_effect = update

        self.handlers.presence_handler.push_update_to_clients = (
                self.mock_update_client)

        hs.handlers.room_member_handler = Mock(spec=[
            "get_rooms_for_user",
        ])
        hs.handlers.room_member_handler.get_rooms_for_user = (
                lambda u: defer.succeed([]))

        # Some local users to test with
        self.u_apple = hs.parse_userid("@apple:test")
        self.u_banana = hs.parse_userid("@banana:test")
        self.u_clementine = hs.parse_userid("@clementine:test")

        # Remote user
        self.u_potato = hs.parse_userid("@potato:remote")

        self.mock_get_joined = (
            self.datastore.get_rooms_for_user_where_membership_is
        )
开发者ID:gitter-badger,项目名称:synapse,代码行数:83,代码来源:test_presencelike.py


注:本文中的synapse.server.HomeServer.get_replication_layer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。