mirror of
https://github.com/progval/irctest.git
synced 2025-04-04 22:39:50 +00:00
add multiline test
This commit is contained in:
@ -64,6 +64,7 @@ BASE_CONFIG = {
|
||||
'nicklen': 32,
|
||||
'topiclen': 390,
|
||||
'whowas-entries': 100,
|
||||
'multiline': {'max-bytes': 4096, 'max-lines': 32,},
|
||||
},
|
||||
|
||||
"history": {
|
||||
|
75
irctest/server_tests/test_multiline.py
Normal file
75
irctest/server_tests/test_multiline.py
Normal file
@ -0,0 +1,75 @@
|
||||
"""
|
||||
<https://ircv3.net/specs/extensions/labeled-response.html>
|
||||
"""
|
||||
|
||||
from irctest import cases
|
||||
|
||||
CAP_NAME = 'draft/multiline'
|
||||
BATCH_TYPE = 'draft/multiline'
|
||||
CONCAT_TAG = 'draft/multiline-concat'
|
||||
FMSGID_TAG = 'draft/fmsgid'
|
||||
|
||||
base_caps = ['message-tags', 'batch', 'echo-message', 'server-time']
|
||||
|
||||
class MultilineTestCase(cases.BaseServerTestCase, cases.OptionalityHelper):
|
||||
|
||||
@cases.SpecificationSelector.requiredBySpecification('Oragono')
|
||||
def testBasic(self):
|
||||
self.connectClient('alice', capabilities=(base_caps + [CAP_NAME]))
|
||||
self.joinChannel(1, '#test')
|
||||
self.connectClient('bob', capabilities=(base_caps + [CAP_NAME]))
|
||||
self.joinChannel(2, '#test')
|
||||
self.connectClient('charlie', capabilities=base_caps)
|
||||
self.joinChannel(3, '#test')
|
||||
|
||||
self.getMessages(1)
|
||||
self.getMessages(2)
|
||||
self.getMessages(3)
|
||||
|
||||
self.sendLine(1, 'BATCH +123 %s #test' % (BATCH_TYPE,))
|
||||
self.sendLine(1, '@batch=123 PRIVMSG #test hello')
|
||||
self.sendLine(1, '@batch=123 PRIVMSG #test :#how is ')
|
||||
self.sendLine(1, '@batch=123;%s PRIVMSG #test :everyone?' % (CONCAT_TAG,))
|
||||
self.sendLine(1, 'BATCH -123')
|
||||
|
||||
echo = self.getMessages(1)
|
||||
batchStart, batchEnd = echo[0], echo[-1]
|
||||
self.assertEqual(batchStart.command, 'BATCH')
|
||||
self.assertEqual(batchEnd.command, 'BATCH')
|
||||
self.assertEqual(batchStart.params[0][1:], batchEnd.params[0][1:])
|
||||
msgid = batchStart.tags.get('msgid')
|
||||
time = batchStart.tags.get('time')
|
||||
assert msgid
|
||||
assert time
|
||||
fmsgids = []
|
||||
privmsgs = echo[1:-1]
|
||||
for msg in privmsgs:
|
||||
self.assertMessageEqual(msg, command='PRIVMSG')
|
||||
self.assertNotIn('msgid', msg.tags)
|
||||
self.assertNotIn('time', msg.tags)
|
||||
fmsgids.append(msg.tags.get(FMSGID_TAG))
|
||||
self.assertIn(CONCAT_TAG, echo[3].tags)
|
||||
|
||||
relay = self.getMessages(2)
|
||||
batchStart, batchEnd = relay[0], relay[-1]
|
||||
self.assertEqual(batchStart.command, 'BATCH')
|
||||
self.assertEqual(batchEnd.command, 'BATCH')
|
||||
self.assertEqual(batchStart.params[0][1:], batchEnd.params[0][1:])
|
||||
self.assertEqual(batchStart.tags.get('msgid'), msgid)
|
||||
self.assertEqual(batchStart.tags.get('time'), time)
|
||||
privmsgs = relay[1:-1]
|
||||
self.assertEqual([msg.tags.get(FMSGID_TAG) for msg in privmsgs], fmsgids)
|
||||
for msg in privmsgs:
|
||||
self.assertMessageEqual(msg, command='PRIVMSG')
|
||||
self.assertNotIn('msgid', msg.tags)
|
||||
self.assertNotIn('time', msg.tags)
|
||||
self.assertIn(CONCAT_TAG, relay[3].tags)
|
||||
|
||||
fallback_relay = self.getMessages(3)
|
||||
relayed_fmsgids = []
|
||||
for msg in fallback_relay:
|
||||
self.assertMessageEqual(msg, command='PRIVMSG')
|
||||
relayed_fmsgids.append(msg.tags.get('msgid'))
|
||||
self.assertEqual(msg.tags.get('time'), time)
|
||||
self.assertNotIn(CONCAT_TAG, msg.tags)
|
||||
self.assertEqual(fmsgids, relayed_fmsgids)
|
Reference in New Issue
Block a user