mirror of https://github.com/progval/irctest.git
Split testJoin into testJoinAllMessages and testJoinNamreply, and add testPartNotInChannel
This commit is contained in:
parent
469eedab89
commit
d75ffcb2f5
|
@ -5,9 +5,6 @@ from irctest import authentication
|
||||||
from irctest.basecontrollers import BaseClientController, DirectoryBasedController
|
from irctest.basecontrollers import BaseClientController, DirectoryBasedController
|
||||||
|
|
||||||
TEMPLATE_CONFIG = """
|
TEMPLATE_CONFIG = """
|
||||||
supybot.plugins: Authentication
|
|
||||||
supybot.plugins.Authentication: True
|
|
||||||
supybot.plugins.Authentication.public: True
|
|
||||||
supybot.directories.conf: {directory}/conf
|
supybot.directories.conf: {directory}/conf
|
||||||
supybot.directories.data: {directory}/data
|
supybot.directories.data: {directory}/data
|
||||||
supybot.directories.migrations: {directory}/migrations
|
supybot.directories.migrations: {directory}/migrations
|
||||||
|
|
|
@ -4,10 +4,11 @@ Section 3.2 of RFC 2812
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from irctest import cases
|
from irctest import cases
|
||||||
|
from irctest.irc_utils import ambiguities
|
||||||
from irctest.irc_utils.message_parser import Message
|
from irctest.irc_utils.message_parser import Message
|
||||||
|
|
||||||
class JoinTestCase(cases.BaseServerTestCase):
|
class JoinTestCase(cases.BaseServerTestCase):
|
||||||
def testJoin(self):
|
def testJoinAllMessages(self):
|
||||||
"""“If a JOIN is successful, the user receives a JOIN message as
|
"""“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
|
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
|
the list of users who are on the channel (using RPL_NAMREPLY), which
|
||||||
|
@ -22,21 +23,68 @@ class JoinTestCase(cases.BaseServerTestCase):
|
||||||
self.connectClient('foo')
|
self.connectClient('foo')
|
||||||
self.sendLine(1, 'JOIN #chan')
|
self.sendLine(1, 'JOIN #chan')
|
||||||
m = self.getMessage(1)
|
m = self.getMessage(1)
|
||||||
|
try:
|
||||||
self.assertMessageEqual(m, command='JOIN', params=['#chan'])
|
self.assertMessageEqual(m, command='JOIN', params=['#chan'])
|
||||||
m = self.getMessage(1)
|
except AssertionError:
|
||||||
got_topic = False
|
pass
|
||||||
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:
|
else:
|
||||||
m = self.assertMessageEqual(m, command='353') # RPL_NAMREPLY
|
|
||||||
m = self.getMessage(1)
|
m = self.getMessage(1)
|
||||||
m = self.assertMessageEqual(m, command='366') # RPL_ENDOFNAMES
|
if m.command in ('331', '332'): # RPL_NOTOPIC, RPL_TOPIC
|
||||||
|
m = self.getMessage(1)
|
||||||
|
self.assertMessageEqual(m, command='353') # RPL_NAMREPLY
|
||||||
|
namreply = m
|
||||||
|
m = self.getMessage(1)
|
||||||
|
self.assertMessageEqual(m, command='366') # RPL_ENDOFNAMES
|
||||||
|
else:
|
||||||
|
self.assertMessageEqual(m, command='353') # RPL_NAMREPLY
|
||||||
|
namreply = m
|
||||||
|
m = self.getMessage(1)
|
||||||
|
self.assertMessageEqual(m, command='366') # RPL_ENDOFNAMES
|
||||||
m = self.getMessage(1)
|
m = self.getMessage(1)
|
||||||
self.assertIn(m.command, ('331', '332'), m) # RPL_NOTOPIC, RPL_TOPIC
|
self.assertIn(m.command, ('331', '332'), m) # RPL_NOTOPIC, RPL_TOPIC
|
||||||
|
|
||||||
|
def testJoinNamreply(self):
|
||||||
|
"""“353 RPL_NAMREPLY
|
||||||
|
"( "=" / "*" / "@" ) <channel>
|
||||||
|
:[ "@" / "+" ] <nick> *( " " [ "@" / "+" ] <nick> )”
|
||||||
|
-- <https://tools.ietf.org/html/rfc2812#section-5.2>
|
||||||
|
"""
|
||||||
|
self.connectClient('foo')
|
||||||
|
self.sendLine(1, 'JOIN #chan')
|
||||||
|
|
||||||
|
for m in self.getMessages(1):
|
||||||
|
if m.command == '353':
|
||||||
|
self.assertIn(len(m.params), (3, 4), m)
|
||||||
|
params = ambiguities.normalize_namreply_params(m.params)
|
||||||
|
self.assertIn(params[1], '=*@', m)
|
||||||
|
self.assertEqual(params[2], '#chan', m)
|
||||||
|
self.assertIn(params[3], {'foo', '@foo', '+foo'}, m)
|
||||||
|
|
||||||
|
|
||||||
|
def testPartNotInChannel(self):
|
||||||
|
"""“442 ERR_NOTONCHANNEL
|
||||||
|
"<channel> :You're not on that channel"
|
||||||
|
|
||||||
|
- Returned by the server whenever a client tries to
|
||||||
|
perform a channel effecting command for which the
|
||||||
|
client isn't a member.”
|
||||||
|
-- <https://tools.ietf.org/html/rfc1459#section-6.1>
|
||||||
|
and <https://tools.ietf.org/html/rfc2812#section-5.2>
|
||||||
|
|
||||||
|
ERR_NOSUCHCHANNEL should only be used for invalid
|
||||||
|
channel names:
|
||||||
|
“403 ERR_NOSUCHCHANNEL
|
||||||
|
"<channel name> :No such channel"
|
||||||
|
|
||||||
|
- Used to indicate the given channel name is invalid.”
|
||||||
|
-- <https://tools.ietf.org/html/rfc1459#section-6.1>
|
||||||
|
and <https://tools.ietf.org/html/rfc2812#section-5.2>
|
||||||
|
"""
|
||||||
|
self.connectClient('foo')
|
||||||
|
self.sendLine(1, 'PART #chan')
|
||||||
|
m = self.getMessage(1)
|
||||||
|
self.assertMessageEqual(m, command='442') # ERR_NOTONCHANNEL
|
||||||
|
|
||||||
def testJoinTwice(self):
|
def testJoinTwice(self):
|
||||||
self.connectClient('foo')
|
self.connectClient('foo')
|
||||||
self.sendLine(1, 'JOIN #chan')
|
self.sendLine(1, 'JOIN #chan')
|
||||||
|
|
Loading…
Reference in New Issue