本文整理汇总了Python中synapse.server.HomeServer.get_event_factory方法的典型用法代码示例。如果您正苦于以下问题:Python HomeServer.get_event_factory方法的具体用法?Python HomeServer.get_event_factory怎么用?Python HomeServer.get_event_factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类synapse.server.HomeServer
的用法示例。
在下文中一共展示了HomeServer.get_event_factory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import get_event_factory [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
示例2: setUp
# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import get_event_factory [as 别名]
def setUp(self):
db_pool = SQLiteMemoryDbPool()
yield db_pool.prepare()
hs = HomeServer("test",
db_pool=db_pool,
)
# Room events need the full datastore, for persist_event() and
# get_room_state()
self.store = hs.get_datastore()
self.event_factory = hs.get_event_factory();
self.room = hs.parse_roomid("!abcde:test")
yield self.store.store_room(self.room.to_string(),
room_creator_user_id="@creator:text",
is_public=True
)
示例3: setUp
# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import get_event_factory [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")
示例4: PduCodecTestCase
# 需要导入模块: from synapse.server import HomeServer [as 别名]
# 或者: from synapse.server.HomeServer import get_event_factory [as 别名]
class PduCodecTestCase(unittest.TestCase):
def setUp(self):
self.hs = HomeServer("blargle.net")
self.event_factory = self.hs.get_event_factory()
self.codec = PduCodec(self.hs)
def test_decode_event_id(self):
self.assertEquals(
("foo", "bar.com"),
decode_event_id("[email protected]", "A")
)
self.assertEquals(
("foo", "bar.com"),
decode_event_id("foo", "bar.com")
)
def test_encode_event_id(self):
self.assertEquals("[email protected]", encode_event_id("A", "B"))
def test_codec_event_id(self):
event_id = "[email protected]"
self.assertEquals(
event_id,
encode_event_id(*decode_event_id(event_id, None))
)
pdu_id = ("aa", "bb.com")
self.assertEquals(
pdu_id,
decode_event_id(encode_event_id(*pdu_id), None)
)
def test_event_from_pdu(self):
pdu = Pdu(
pdu_id="foo",
context="rooooom",
pdu_type="m.room.message",
origin="bar.com",
ts=12345,
depth=5,
prev_pdus=[("alice", "bob.com")],
is_state=False,
content={"msgtype": u"test"},
)
event = self.codec.event_from_pdu(pdu)
self.assertEquals("[email protected]", event.event_id)
self.assertEquals(pdu.context, event.room_id)
self.assertEquals(pdu.is_state, event.is_state)
self.assertEquals(pdu.depth, event.depth)
self.assertEquals(["[email protected]"], event.prev_events)
self.assertEquals(pdu.content, event.content)
def test_pdu_from_event(self):
event = self.event_factory.create_event(
etype="m.room.message",
event_id="gargh_id",
room_id="rooom",
user_id="sender",
content={"msgtype": u"test"},
)
pdu = self.codec.pdu_from_event(event)
self.assertEquals(event.event_id, pdu.pdu_id)
self.assertEquals(self.hs.hostname, pdu.origin)
self.assertEquals(event.room_id, pdu.context)
self.assertEquals(event.content, pdu.content)
self.assertEquals(event.type, pdu.pdu_type)
event = self.event_factory.create_event(
etype="m.room.message",
event_id="[email protected]",
room_id="rooom",
user_id="sender",
content={"msgtype": u"test"},
)
pdu = self.codec.pdu_from_event(event)
self.assertEquals("gargh_id", pdu.pdu_id)
self.assertEquals("bob.com", pdu.origin)
self.assertEquals(event.room_id, pdu.context)
self.assertEquals(event.content, pdu.content)
self.assertEquals(event.type, pdu.pdu_type)
def test_event_from_state_pdu(self):
pdu = Pdu(
pdu_id="foo",
context="rooooom",
pdu_type="m.room.topic",
origin="bar.com",
ts=12345,
depth=5,
prev_pdus=[("alice", "bob.com")],
#.........这里部分代码省略.........