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


Python HomeServer.parse_userid方法代码示例

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


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

示例1: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        db_pool = SQLiteMemoryDbPool()
        yield db_pool.prepare()

        self.mock_config = Mock()
        self.mock_config.signing_key = [MockKey()]

        hs = HomeServer(
            "test",
            db_pool=db_pool,
            config=self.mock_config,
            resource_for_federation=Mock(),
            http_client=None,
        )
        # We can't test the RoomMemberStore on its own without the other event
        # storage logic
        self.store = hs.get_datastore()
        self.event_builder_factory = hs.get_event_builder_factory()
        self.handlers = hs.get_handlers()
        self.message_handler = self.handlers.message_handler

        self.u_alice = hs.parse_userid("@alice:test")
        self.u_bob = hs.parse_userid("@bob:test")

        # User elsewhere on another host
        self.u_charlie = hs.parse_userid("@charlie:elsewhere")

        self.room = hs.parse_roomid("!abc123:test")
开发者ID:alisheikh,项目名称:synapse,代码行数:30,代码来源:test_roommember.py

示例2: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        self.mock_federation = Mock(spec=[
            "make_query",
        ])

        self.query_handlers = {}
        def register_query_handler(query_type, handler):
            self.query_handlers[query_type] = handler
        self.mock_federation.register_query_handler = register_query_handler

        hs = HomeServer("test",
                db_pool=None,
                http_client=None,
                datastore=Mock(spec=[
                    "get_profile_displayname",
                    "set_profile_displayname",
                    "get_profile_avatar_url",
                    "set_profile_avatar_url",
                ]),
                handlers=None,
                resource_for_federation=Mock(),
                replication_layer=self.mock_federation,
            )
        hs.handlers = ProfileHandlers(hs)

        self.datastore = hs.get_datastore()

        self.frank = hs.parse_userid("@1234ABCD:test")
        self.bob   = hs.parse_userid("@4567:test")
        self.alice = hs.parse_userid("@alice:remote")

        self.handler = hs.get_handlers().profile_handler

        # TODO(paul): Icky signal declarings.. booo
        hs.get_distributor().declare("changed_presencelike_data")
开发者ID:martindale,项目名称:synapse,代码行数:37,代码来源:test_profile.py

示例3: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        db_pool = SQLiteMemoryDbPool()
        yield db_pool.prepare()

        self.mock_config = Mock()
        self.mock_config.signing_key = [MockKey()]

        hs = HomeServer(
            "test",
            db_pool=db_pool,
            config=self.mock_config,
            resource_for_federation=Mock(),
            http_client=None,
        )

        self.store = hs.get_datastore()
        self.event_builder_factory = hs.get_event_builder_factory()
        self.handlers = hs.get_handlers()
        self.message_handler = self.handlers.message_handler

        self.u_alice = hs.parse_userid("@alice:test")
        self.u_bob = hs.parse_userid("@bob:test")

        self.room1 = hs.parse_roomid("!abc123:test")
        self.room2 = hs.parse_roomid("!xyx987:test")

        self.depth = 1
开发者ID:alisheikh,项目名称:synapse,代码行数:29,代码来源:test_stream.py

示例4: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        self.mock_federation = Mock(spec=[
            "make_query",
        ])

        self.query_handlers = {}
        def register_query_handler(query_type, handler):
            self.query_handlers[query_type] = handler
        self.mock_federation.register_query_handler = register_query_handler

        db_pool = SQLiteMemoryDbPool()
        yield db_pool.prepare()

        hs = HomeServer("test",
                db_pool=db_pool,
                http_client=None,
                handlers=None,
                resource_for_federation=Mock(),
                replication_layer=self.mock_federation,
            )
        hs.handlers = ProfileHandlers(hs)

        self.store = hs.get_datastore()

        self.frank = hs.parse_userid("@1234ABCD:test")
        self.bob   = hs.parse_userid("@4567:test")
        self.alice = hs.parse_userid("@alice:remote")

        yield self.store.create_profile(self.frank.localpart)

        self.handler = hs.get_handlers().profile_handler

        # TODO(paul): Icky signal declarings.. booo
        hs.get_distributor().declare("changed_presencelike_data")
开发者ID:gitter-badger,项目名称:synapse,代码行数:36,代码来源:test_profile.py

示例5: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        db_pool = SQLiteMemoryDbPool()
        yield db_pool.prepare()

        hs = HomeServer("test",
            clock=MockClock(),
            db_pool=db_pool,
            handlers=None,
            resource_for_federation=Mock(),
            http_client=None,
        )
        hs.handlers = JustPresenceHandlers(hs)

        self.store = hs.get_datastore()

        # Mock the RoomMemberHandler
        room_member_handler = Mock(spec=[])
        hs.handlers.room_member_handler = room_member_handler

        # 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")

        yield self.store.create_presence(self.u_apple.localpart)
        yield self.store.set_presence_state(
            self.u_apple.localpart, {"state": ONLINE, "status_msg": "Online"}
        )

        self.handler = hs.get_handlers().presence_handler

        self.room_members = []

        def get_rooms_for_user(user):
            if user in self.room_members:
                return defer.succeed(["a-room"])
            else:
                return defer.succeed([])
        room_member_handler.get_rooms_for_user = get_rooms_for_user

        def get_room_members(room_id):
            if room_id == "a-room":
                return defer.succeed(self.room_members)
            else:
                return defer.succeed([])
        room_member_handler.get_room_members = get_room_members

        def user_rooms_intersect(userlist):
            room_member_ids = map(lambda u: u.to_string(), self.room_members)

            shared = all(map(lambda i: i in room_member_ids, userlist))
            return defer.succeed(shared)
        self.store.user_rooms_intersect = user_rooms_intersect

        self.mock_start = Mock()
        self.mock_stop = Mock()

        self.handler.start_polling_presence = self.mock_start
        self.handler.stop_polling_presence = self.mock_stop
开发者ID:uroborus,项目名称:synapse,代码行数:61,代码来源:test_presence.py

示例6: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
        self.mock_config = Mock()
        self.mock_config.signing_key = [MockKey()]

        hs = HomeServer("test",
            db_pool=None,
            datastore=Mock(spec=[
                "has_presence_state",
                "get_presence_state",
                "allow_presence_visible",
                "is_presence_visible",
                "add_presence_list_pending",
                "set_presence_list_accepted",
                "del_presence_list",
                "get_presence_list",
                "insert_client_ip",
            ]),
            http_client=None,
            resource_for_client=self.mock_resource,
            resource_for_federation=self.mock_resource,
            config=self.mock_config,
        )
        hs.handlers = JustPresenceHandlers(hs)

        self.datastore = hs.get_datastore()

        def has_presence_state(user_localpart):
            return defer.succeed(
                user_localpart in ("apple", "banana",)
            )
        self.datastore.has_presence_state = has_presence_state

        def _get_user_by_token(token=None):
            return {
                "user": hs.parse_userid(myid),
                "admin": False,
                "device_id": None,
            }

        room_member_handler = hs.handlers.room_member_handler = Mock(
            spec=[
                "get_rooms_for_user",
            ]
        )

        hs.get_auth().get_user_by_token = _get_user_by_token

        hs.register_servlets()

        self.u_apple = hs.parse_userid("@apple:test")
        self.u_banana = hs.parse_userid("@banana:test")
开发者ID:alisheikh,项目名称:synapse,代码行数:54,代码来源:test_presence.py

示例7: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        self.mock_http_client = Mock(spec=[])
        self.mock_http_client.put_json = DeferredMockCallable()

        self.mock_federation_resource = MockHttpResource()

        db_pool = SQLiteMemoryDbPool()
        yield db_pool.prepare()

        self.mock_config = NonCallableMock()
        self.mock_config.signing_key = [MockKey()]

        hs = HomeServer("test",
            clock=MockClock(),
            db_pool=db_pool,
            handlers=None,
            resource_for_client=Mock(),
            resource_for_federation=self.mock_federation_resource,
            http_client=self.mock_http_client,
            config=self.mock_config,
            keyring=Mock(),
        )
        hs.handlers = JustPresenceHandlers(hs)

        self.store = hs.get_datastore()

        # Some local users to test with
        self.u_apple = hs.parse_userid("@apple:test")
        self.u_banana = hs.parse_userid("@banana:test")
        yield self.store.create_presence(self.u_apple.localpart)
        yield self.store.create_presence(self.u_banana.localpart)

        # ID of a local user that does not exist
        self.u_durian = hs.parse_userid("@durian:test")

        # A remote user
        self.u_cabbage = hs.parse_userid("@cabbage:elsewhere")

        self.handler = hs.get_handlers().presence_handler

        self.mock_start = Mock()
        self.mock_stop = Mock()

        self.handler.start_polling_presence = self.mock_start
        self.handler.stop_polling_presence = self.mock_stop
开发者ID:winsontan520,项目名称:synapse,代码行数:47,代码来源:test_presence.py

示例8: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        db_pool = SQLiteMemoryDbPool()
        yield db_pool.prepare()

        hs = HomeServer(
            "test",
            db_pool=db_pool,
        )

        self.store = hs.get_datastore()
        self.event_factory = hs.get_event_factory()

        self.u_alice = hs.parse_userid("@alice:test")
        self.u_bob = hs.parse_userid("@bob:test")

        self.room1 = hs.parse_roomid("!abc123:test")

        self.depth = 1
开发者ID:gitter-badger,项目名称:synapse,代码行数:20,代码来源:test_redaction.py

示例9: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        db_pool = SQLiteMemoryDbPool()
        yield db_pool.prepare()

        hs = HomeServer("test",
            db_pool=db_pool,
        )

        # We can't test the RoomMemberStore on its own without the other event
        # storage logic
        self.store = hs.get_datastore()
        self.event_factory = hs.get_event_factory()

        self.u_alice = hs.parse_userid("@alice:test")
        self.u_bob = hs.parse_userid("@bob:test")

        # User elsewhere on another host
        self.u_charlie = hs.parse_userid("@charlie:elsewhere")

        self.room = hs.parse_roomid("!abc123:test")
开发者ID:esaul,项目名称:synapse,代码行数:22,代码来源:test_roommember.py

示例10: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        db_pool = SQLiteMemoryDbPool()
        yield db_pool.prepare()

        hs = HomeServer("test",
            db_pool=db_pool,
        )

        self.store = ProfileStore(hs)

        self.u_frank = hs.parse_userid("@frank:test")
开发者ID:alisheikh,项目名称:synapse,代码行数:13,代码来源:test_profile.py

示例11: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        self.mock_resource = MockHttpResource(prefix=PATH_PREFIX)
        self.auth_user_id = self.user_id

        self.mock_config = NonCallableMock()
        self.mock_config.signing_key = [MockKey()]

        db_pool = SQLiteMemoryDbPool()
        yield db_pool.prepare()

        hs = HomeServer(
            "red",
            db_pool=db_pool,
            http_client=None,
            replication_layer=Mock(),
            ratelimiter=NonCallableMock(spec_set=[
                "send_message",
            ]),
            config=self.mock_config,
        )
        self.ratelimiter = hs.get_ratelimiter()
        self.ratelimiter.send_message.return_value = (True, 0)

        hs.get_handlers().federation_handler = Mock()

        def _get_user_by_token(token=None):
            return {
                "user": hs.parse_userid(self.auth_user_id),
                "admin": False,
                "device_id": None,
            }
        hs.get_auth().get_user_by_token = _get_user_by_token

        def _insert_client_ip(*args, **kwargs):
            return defer.succeed(None)
        hs.get_datastore().insert_client_ip = _insert_client_ip

        synapse.rest.room.register_servlets(hs, self.mock_resource)

        # Since I'm getting my own presence I need to exist as far as presence
        # is concerned.
        hs.get_handlers().presence_handler.registered_user(
            hs.parse_userid(self.user_id)
        )

        # create the room
        self.room_id = yield self.create_room_as(self.user_id)
开发者ID:alisheikh,项目名称:synapse,代码行数:49,代码来源:test_rooms.py

示例12: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        db_pool = SQLiteMemoryDbPool()
        yield db_pool.prepare()

        hs = HomeServer("test",
            db_pool=db_pool,
        )

        # We can't test RoomStore on its own without the DirectoryStore, for
        # management of the 'room_aliases' table
        self.store = hs.get_datastore()

        self.room = hs.parse_roomid("!abcde:test")
        self.alias = hs.parse_roomalias("#a-room-name:test")
        self.u_creator = hs.parse_userid("@creator:test")

        yield self.store.store_room(self.room.to_string(),
            room_creator_user_id=self.u_creator.to_string(),
            is_public=True
        )
开发者ID:alisheikh,项目名称:synapse,代码行数:22,代码来源:test_room.py

示例13: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        self.clock = MockClock()

        self.mock_http_client = Mock(spec=[])
        self.mock_http_client.put_json = DeferredMockCallable()

        self.mock_federation_resource = MockHttpResource()

        self.mock_config = Mock()
        self.mock_config.signing_key = [MockKey()]

        mock_notifier = Mock(spec=["on_new_user_event"])
        self.on_new_user_event = mock_notifier.on_new_user_event

        self.auth = Mock(spec=[])

        hs = HomeServer("test",
                auth=self.auth,
                clock=self.clock,
                db_pool=None,
                datastore=Mock(spec=[
                    # Bits that Federation needs
                    "prep_send_transaction",
                    "delivered_txn",
                    "get_received_txn_response",
                    "set_received_txn_response",
                    "get_destination_retry_timings",
                ]),
                handlers=None,
                notifier=mock_notifier,
                resource_for_client=Mock(),
                resource_for_federation=self.mock_federation_resource,
                http_client=self.mock_http_client,
                config=self.mock_config,
                keyring=Mock(),
            )
        hs.handlers = JustTypingNotificationHandlers(hs)

        self.handler = hs.get_handlers().typing_notification_handler

        self.event_source = hs.get_event_sources().sources["typing"]

        self.datastore = hs.get_datastore()
        self.datastore.get_destination_retry_timings.return_value = (
            defer.succeed(DestinationsTable.EntryType("", 0, 0))
        )

        def get_received_txn_response(*args):
            return defer.succeed(None)
        self.datastore.get_received_txn_response = get_received_txn_response

        self.room_id = "a-room"

        # Mock the RoomMemberHandler
        hs.handlers.room_member_handler = Mock(spec=[])
        self.room_member_handler = hs.handlers.room_member_handler

        self.room_members = []

        def get_rooms_for_user(user):
            if user in self.room_members:
                return defer.succeed([self.room_id])
            else:
                return defer.succeed([])
        self.room_member_handler.get_rooms_for_user = get_rooms_for_user

        def get_room_members(room_id):
            if room_id == self.room_id:
                return defer.succeed(self.room_members)
            else:
                return defer.succeed([])
        self.room_member_handler.get_room_members = get_room_members

        @defer.inlineCallbacks
        def fetch_room_distributions_into(room_id, localusers=None,
                remotedomains=None, ignore_user=None):

            members = yield get_room_members(room_id)
            for member in members:
                if ignore_user is not None and member == ignore_user:
                    continue

                if hs.is_mine(member):
                    if localusers is not None:
                        localusers.add(member)
                else:
                    if remotedomains is not None:
                        remotedomains.add(member.domain)
        self.room_member_handler.fetch_room_distributions_into = (
                fetch_room_distributions_into)

        def check_joined_room(room_id, user_id):
            if user_id not in [u.to_string() for u in self.room_members]:
                raise AuthError(401, "User is not in the room")

        self.auth.check_joined_room = check_joined_room

        # Some local users to test with
        self.u_apple = hs.parse_userid("@apple:test")
        self.u_banana = hs.parse_userid("@banana:test")
#.........这里部分代码省略.........
开发者ID:alisheikh,项目名称:synapse,代码行数:103,代码来源:test_typing.py

示例14: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [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

示例15: setUp

# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import parse_userid [as 别名]
    def setUp(self):
        self.clock = MockClock()

        self.mock_http_client = Mock(spec=[])
        self.mock_http_client.put_json = DeferredMockCallable()

        self.mock_federation_resource = MockHttpResource()

        self.mock_config = Mock()
        self.mock_config.signing_key = [MockKey()]

        hs = HomeServer("test",
                clock=self.clock,
                db_pool=None,
                datastore=Mock(spec=[
                    # Bits that Federation needs
                    "prep_send_transaction",
                    "delivered_txn",
                    "get_received_txn_response",
                    "set_received_txn_response",
                ]),
                handlers=None,
                resource_for_client=Mock(),
                resource_for_federation=self.mock_federation_resource,
                http_client=self.mock_http_client,
                config=self.mock_config,
                keyring=Mock(),
            )
        hs.handlers = JustTypingNotificationHandlers(hs)

        self.mock_update_client = Mock()
        self.mock_update_client.return_value = defer.succeed(None)

        self.handler = hs.get_handlers().typing_notification_handler
        self.handler.push_update_to_clients = self.mock_update_client

        self.datastore = hs.get_datastore()

        def get_received_txn_response(*args):
            return defer.succeed(None)
        self.datastore.get_received_txn_response = get_received_txn_response

        self.room_id = "a-room"

        # Mock the RoomMemberHandler
        hs.handlers.room_member_handler = Mock(spec=[])
        self.room_member_handler = hs.handlers.room_member_handler

        self.room_members = []

        def get_rooms_for_user(user):
            if user in self.room_members:
                return defer.succeed([self.room_id])
            else:
                return defer.succeed([])
        self.room_member_handler.get_rooms_for_user = get_rooms_for_user

        def get_room_members(room_id):
            if room_id == self.room_id:
                return defer.succeed(self.room_members)
            else:
                return defer.succeed([])
        self.room_member_handler.get_room_members = get_room_members

        @defer.inlineCallbacks
        def fetch_room_distributions_into(room_id, localusers=None,
                remotedomains=None, ignore_user=None):

            members = yield get_room_members(room_id)
            for member in members:
                if ignore_user is not None and member == ignore_user:
                    continue

                if member.is_mine:
                    if localusers is not None:
                        localusers.add(member)
                else:
                    if remotedomains is not None:
                        remotedomains.add(member.domain)
        self.room_member_handler.fetch_room_distributions_into = (
                fetch_room_distributions_into)

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

        # Remote user
        self.u_onion = hs.parse_userid("@onion:farm")
开发者ID:esaul,项目名称:synapse,代码行数:90,代码来源:test_typing.py


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