mirror of
https://github.com/progval/irctest.git
synced 2025-04-06 23:39:46 +00:00
Add server tests for JOIN.
This commit is contained in:
46
irctest/server_tests/test_channel_operations.py
Normal file
46
irctest/server_tests/test_channel_operations.py
Normal file
@ -0,0 +1,46 @@
|
||||
"""
|
||||
Section 3.2 of RFC 2812
|
||||
<https://tools.ietf.org/html/rfc2812#section-3.2>
|
||||
"""
|
||||
|
||||
from irctest import cases
|
||||
from irctest.irc_utils.message_parser import Message
|
||||
|
||||
class JoinTestCase(cases.BaseServerTestCase):
|
||||
def testJoin(self):
|
||||
"""“If a JOIN is successful, the user receives a JOIN message as
|
||||
confirmation and is then sent the channel's topic (using RPL_TOPIC) and
|
||||
the list of users who are on the channel (using RPL_NAMREPLY), which
|
||||
MUST include the user joining.”
|
||||
-- <https://tools.ietf.org/html/rfc2812#section-3.2.1>
|
||||
|
||||
“If a JOIN is successful, the user is then sent the channel's topic
|
||||
(using RPL_TOPIC) and the list of users who are on the channel (using
|
||||
RPL_NAMREPLY), which must include the user joining.”
|
||||
-- <https://tools.ietf.org/html/rfc1459#section-4.2.1>
|
||||
"""
|
||||
self.connectClient('foo')
|
||||
self.sendLine(1, 'JOIN #chan')
|
||||
m = self.getMessage(1)
|
||||
self.assertMessageEqual(m, command='JOIN', params=['#chan'])
|
||||
m = self.getMessage(1)
|
||||
got_topic = False
|
||||
if m.command in ('331', '332'): # RPL_NOTOPIC, RPL_TOPIC
|
||||
got_topic = True
|
||||
m = self.getMessage(1)
|
||||
m = self.assertMessageEqual(m, command='353') # RPL_NAMREPLY
|
||||
m = self.getMessage(1)
|
||||
m = self.assertMessageEqual(m, command='366') # RPL_ENDOFNAMES
|
||||
else:
|
||||
m = self.assertMessageEqual(m, command='353') # RPL_NAMREPLY
|
||||
m = self.getMessage(1)
|
||||
m = self.assertMessageEqual(m, command='366') # RPL_ENDOFNAMES
|
||||
m = self.getMessage(1)
|
||||
self.assertIn(m.command, ('331', '332'), m) # RPL_NOTOPIC, RPL_TOPIC
|
||||
def testJoinTwice(self):
|
||||
self.connectClient('foo')
|
||||
self.sendLine(1, 'JOIN #chan')
|
||||
m = self.getMessage(1)
|
||||
self.assertMessageEqual(m, command='JOIN', params=['#chan'])
|
||||
self.sendLine(1, 'JOIN #chan')
|
||||
# What should we do now?
|
Reference in New Issue
Block a user