async def test_handle_unknown_type(df_loop, listener, initiator): payload = V4Payload(symphony_elements_action=V4SymphonyElementsAction()) event = V4Event(type="unknown", payload=payload, initiator=initiator) await create_and_await_tasks(df_loop, [event]) listener.assert_not_awaited()
def fixture_bot_message_sent_event(): initiator = V4Initiator(user=V4User(user_id=BOT_USER_ID)) payload = V4Payload(message_sent=V4MessageSent(message=V4Message( message="message"))) return V4Event(type=RealTimeEvent.MESSAGESENT.name, payload=payload, initiator=initiator)
async def test_handle_symphony_element(df_loop, listener, initiator): payload = V4Payload(symphony_elements_action=V4SymphonyElementsAction()) event = V4Event(type=RealTimeEvent.SYMPHONYELEMENTSACTION.name, payload=payload, initiator=initiator) await create_and_await_tasks(df_loop, [event]) listener.on_symphony_elements_action.assert_called_once_with( initiator, payload.symphony_elements_action)
async def test_handle_connection_accepted(df_loop, listener, initiator): payload = V4Payload(connection_accepted=V4ConnectionAccepted()) event = V4Event(type=RealTimeEvent.CONNECTIONACCEPTED.name, payload=payload, initiator=initiator) await create_and_await_tasks(df_loop, [event]) listener.on_connection_accepted.assert_called_with( initiator, payload.connection_accepted)
async def test_handle_message_suppressed(df_loop, listener, initiator): payload = V4Payload(message_suppressed=V4MessageSuppressed()) event = V4Event(type=RealTimeEvent.MESSAGESUPPRESSED.name, payload=payload, initiator=initiator) await create_and_await_tasks(df_loop, [event]) listener.on_message_suppressed.assert_called_with( initiator, payload.message_suppressed)
async def test_handle_user_left_room(df_loop, listener, initiator): payload = V4Payload(user_left_room=V4UserLeftRoom()) event = V4Event(type=RealTimeEvent.USERLEFTROOM.name, payload=payload, initiator=initiator) await create_and_await_tasks(df_loop, [event]) listener.on_user_left_room.assert_called_with(initiator, payload.user_left_room)
async def test_handle_room_deactivated(df_loop, listener, initiator): payload = V4Payload(room_deactivated=V4RoomDeactivated()) event = V4Event(type=RealTimeEvent.ROOMDEACTIVATED.name, payload=payload, initiator=initiator) await create_and_await_tasks(df_loop, [event]) listener.on_room_deactivated.assert_called_with(initiator, payload.room_deactivated)
async def test_handle_instant_message_created(df_loop, listener, initiator): payload = V4Payload(instant_message_created=V4InstantMessageCreated()) event = V4Event(type=RealTimeEvent.INSTANTMESSAGECREATED.name, payload=payload, initiator=initiator) await create_and_await_tasks(df_loop, [event]) listener.on_instant_message_created.assert_called_with( initiator, payload.instant_message_created)
async def test_handle_shared_post(df_loop, listener, initiator): payload = V4Payload(shared_post=V4SharedPost()) event = V4Event(type=RealTimeEvent.SHAREDPOST.name, payload=payload, initiator=initiator) await create_and_await_tasks(df_loop, [event]) listener.on_shared_post.assert_called_once_with(initiator, payload.shared_post)
async def test_handle_message_sent(df_loop, listener, initiator): payload = V4Payload(message_sent=V4MessageSent()) event = V4Event(type=RealTimeEvent.MESSAGESENT.name, payload=payload, initiator=initiator) tasks = await df_loop._create_listener_tasks([event]) await asyncio.gather(*tasks) listener.on_message_sent.assert_called_once_with(initiator, payload.message_sent)
async def test_handle_room_member_demoted_from_owner(df_loop, listener, initiator): payload = V4Payload( room_member_demoted_from_owner=V4RoomMemberDemotedFromOwner()) event = V4Event(type=RealTimeEvent.ROOMMEMBERDEMOTEDFROMOWNER.name, payload=payload, initiator=initiator) await create_and_await_tasks(df_loop, [event]) listener.on_room_demoted_from_owner.assert_called_with( initiator, payload.room_member_demoted_from_owner)
async def test_handle_user_requested_to_join_room(df_loop, listener, initiator): payload = V4Payload( user_requested_to_join_room=V4UserRequestedToJoinRoom()) event = V4Event(type=RealTimeEvent.USERREQUESTEDTOJOINROOM.name, payload=payload, initiator=initiator) await create_and_await_tasks(df_loop, [event]) listener.on_user_requested_to_join_room.assert_called_with( initiator, payload.user_requested_to_join_room)
def fixture_message_sent(initiator): return V4Event(type=RealTimeEvent.MESSAGESENT.name, payload=V4Payload(message_sent=V4MessageSent()), initiator=initiator)
def fixture_message_sent(): initiator = V4Initiator(user=V4User(username="******")) return V4Event(type=RealTimeEvent.MESSAGESENT.name, payload=V4Payload(message_sent=V4MessageSent()), initiator=initiator)
def fixture_message_sent_event(initiator): payload = V4Payload(message_sent=V4MessageSent(message=V4Message( message="message"))) return V4Event(type=RealTimeEvent.MESSAGESENT.name, payload=payload, initiator=initiator)