예제 #1
0
    def test_help_command(self, mock_irc_IRCClient, mock_say):
        command = '.help'
        self.assertIn(command, commands.keys())
        hostmask = self.validhostmasks[0]

        self.bot.privmsg(hostmask, self.bot.channel, command)
        self.assertTrue(mock_say.called)
예제 #2
0
    def test_join_question_queue_command(self, mock_describe,
            mock_irc_IRCClient):
        self.assertListEqual([], self.bot.qs_queue) # Ensure queue is empty
        
        command = '!'
        self.assertIn(command, commands.keys())

        # Add users to queue
        for hostmask in self.validhostmasks:
            self.bot.privmsg(hostmask, self.bot.channel, '!')
            assert(mock_describe.called)
            self.assertIn(IRCUser(self.bot, hostmask).nick, self.bot.qs_queue)
            self.assertEquals(IRCUser(self.bot, hostmask).nick, self.bot.qs_queue[-1])
예제 #3
0
    def test_leave_question_queue_command(self, mock_irc_IRCClient,
            mock_describe):
        self.assertListEqual([], self.bot.qs_queue) # Ensure queue is empty
        
        leave_queue_commands = ('!!', '!-')
        join_queue_command = '!'
        self.assertIn(join_queue_command, commands.keys())

        for command in leave_queue_commands:
            self.assertIn(command, commands.keys())

            # First, join queue
            hostmask = self.validhostmasks[0]
            self.bot.privmsg(hostmask, self.bot.channel, join_queue_command)
            assert(mock_describe.called)
            self.assertIn(IRCUser(self.bot, hostmask).nick, self.bot.qs_queue)
            self.assertEquals(IRCUser(self.bot, hostmask).nick, self.bot.qs_queue[-1])

            # Then, leave queue
            # Only one user in queue, it should be empty afterwards
            self.bot.privmsg(hostmask, self.bot.channel, command)
            assert(mock_describe.called)
            self.assertListEqual([], self.bot.qs_queue)