<commit_before>
"""
Test that messages that are sent within the same message delivery timeout
(default 2s) get delivered in the proper order.  This bug was fixed in rev
8fae4404798, this is just a regression test to ensure that it stays fixed
"""

from idletest import exec_test
from servicetest import EventPattern, call_async
import dbus

def test(q, bus, conn, stream):
    conn.Connect()
    q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
    CHANNEL_NAME = '#idletest'
    room_handles = conn.RequestHandles(2, [CHANNEL_NAME])
    call_async(q, conn, 'RequestChannel', 'org.freedesktop.Telepathy.Channel.Type.Text', 2, room_handles[0], True)

    ret = q.expect('dbus-return', method='RequestChannel')
    q.expect('dbus-signal', signal='MembersChanged')
    chan = bus.get_object(conn.bus_name, ret.value[0])

    text_chan = dbus.Interface(chan,
        u'org.freedesktop.Telepathy.Channel.Type.Text')
    # send a whole bunch of messages in a row
    call_async(q, text_chan, 'Send', 0, '0')
    call_async(q, text_chan, 'Send', 0, '1')
    call_async(q, text_chan, 'Send', 0, '2')
    call_async(q, text_chan, 'Send', 0, '3')
    call_async(q, text_chan, 'Send', 0, '4')

    q.expect('irc-privmsg', data={'message':'0','recipient':CHANNEL_NAME})
    q.expect('irc-privmsg', data={'message':'1','recipient':CHANNEL_NAME})
    q.expect('irc-privmsg', data={'message':'2','recipient':CHANNEL_NAME})
    q.expect('irc-privmsg', data={'message':'3','recipient':CHANNEL_NAME})
    q.expect('irc-privmsg', data={'message':'4','recipient':CHANNEL_NAME})

    call_async(q, conn, 'Disconnect')
    return True

if __name__ == '__main__':
    exec_test(test)

<commit_msg>message-order test: use loop to make this a bit cleaner<commit_after>
"""
Test that messages that are sent within the same message delivery timeout
(default 2s) get delivered in the proper order.  This bug was fixed in rev
8fae4404798, this is just a regression test to ensure that it stays fixed
"""

from idletest import exec_test
from servicetest import EventPattern, call_async
import dbus

def test(q, bus, conn, stream):
    conn.Connect()
    q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
    CHANNEL_NAME = '#idletest'
    room_handles = conn.RequestHandles(2, [CHANNEL_NAME])
    call_async(q, conn, 'RequestChannel', 'org.freedesktop.Telepathy.Channel.Type.Text', 2, room_handles[0], True)

    ret = q.expect('dbus-return', method='RequestChannel')
    q.expect('dbus-signal', signal='MembersChanged')
    chan = bus.get_object(conn.bus_name, ret.value[0])

    text_chan = dbus.Interface(chan,
        u'org.freedesktop.Telepathy.Channel.Type.Text')

    # send a whole bunch of messages in a row and make sure they get delivered
    # in the proper order
    for i in range(4):
        call_async(q, text_chan, 'Send', 0, str(i))

    for i in range(4):
        q.expect('irc-privmsg', data={'message':str(i),'recipient':CHANNEL_NAME})

    call_async(q, conn, 'Disconnect')
    return True

if __name__ == '__main__':
    exec_test(test)


{'fraction_non_alphanumeric': 0.14112639161755075, 'fraction_numerical': 0.015717092337917484, 'mean_word_length': 4.465116279069767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5311448', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1004, 'n_words': 273}