diff --git a/irctest/server_tests/test_channel_operations.py b/irctest/server_tests/test_channel_operations.py new file mode 100644 index 0000000..2a6ff0d --- /dev/null +++ b/irctest/server_tests/test_channel_operations.py @@ -0,0 +1,46 @@ +""" +Section 3.2 of RFC 2812 + +""" + +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.” + -- + + “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.” + -- + """ + 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?