예제 #1
0
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()
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
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)
예제 #7
0
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)
예제 #8
0
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)
예제 #9
0
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)
예제 #10
0
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)
예제 #11
0
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)
예제 #12
0
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)
예제 #13
0
def fixture_message_sent(initiator):
    return V4Event(type=RealTimeEvent.MESSAGESENT.name,
                   payload=V4Payload(message_sent=V4MessageSent()),
                   initiator=initiator)
예제 #14
0
def fixture_message_sent():
    initiator = V4Initiator(user=V4User(username="******"))
    return V4Event(type=RealTimeEvent.MESSAGESENT.name,
                   payload=V4Payload(message_sent=V4MessageSent()),
                   initiator=initiator)
예제 #15
0
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)