Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
test_xmppbot.TestXMPPBotCommands Class Reference

List of all members.

Public Member Functions

def setup_class
def setup_method
def dummy_method
def testNotificationCommand
def testRosterCommands
def testInternalHelp

Public Attributes

 from_xmlrpc
 to_xmlrpc
 bot
 called

Detailed Description

Various tests for the XMPP bot receiving commands from Wiki

Definition at line 21 of file test_xmppbot.py.


Member Function Documentation

def test_xmppbot.TestXMPPBotCommands.dummy_method (   self,
  args,
  kwargs 
)

Definition at line 35 of file test_xmppbot.py.

00035 
00036     def dummy_method(self, *args, **kwargs):
00037         self.called = True

Definition at line 24 of file test_xmppbot.py.

00024 
00025     def setup_class(self):
00026         self.from_xmlrpc = Queue()
00027         self.to_xmlrpc = Queue()
00028         self.bot = XMPPBot(BotConfig, self.from_xmlrpc, self.to_xmlrpc)

def test_xmppbot.TestXMPPBotCommands.setup_method (   self,
  method 
)

Definition at line 29 of file test_xmppbot.py.

00029 
00030     def setup_method(self, method):
00031         self.called = False
00032         self.bot.send_message = self.dummy_method
00033         self.bot.ask_for_subscription = self.dummy_method
00034         self.bot.remove_subscription = self.dummy_method

Check if there's help for every known command

Definition at line 81 of file test_xmppbot.py.

00081 
00082     def testInternalHelp(self):
00083         """Check if there's help for every known command"""
00084 
00085         commands = self.bot.internal_commands + self.bot.xmlrpc_commands.values()
00086         for cmd in commands:
00087             print "There should be help on %s command!" % (cmd, )
00088             assert self.bot.help_on("dude@example.com", cmd)
Check if send_message is triggered for tested commands

Definition at line 38 of file test_xmppbot.py.

00038 
00039     def testNotificationCommand(self):
00040         """Check if send_message is triggered for tested commands"""
00041 
00042         data = {'text': 'Some notification', 'subject': 'It is optional', 'url_list': []}
00043         cmds = []
00044         cmds.append(commands.NotificationCommand(["dude@example.com"], data, True))
00045         cmds.append(commands.NotificationCommandI18n(["dude@example.com"], data, True))
00046         cmds.append(commands.GetPage("dude@example.com", "TestPage"))
00047         cmds.append(commands.GetPageHTML("dude@example.com", "TestPage"))
00048 
00049         tmp_cmd = commands.GetPageList("dude@example.com")
00050         tmp_cmd.data = ""
00051         cmds.append(tmp_cmd)
00052 
00053         tmp_cmd = commands.GetPageInfo("dude@example.com", "TestPage")
00054         tmp_cmd.data = {'author': 'dude', 'lastModified': '200708060T34350', 'version': 42}
00055         cmds.append(tmp_cmd)
00056 
00057         for cmd in cmds:
00058             self.called = False
00059             self.bot.handle_command(cmd)
00060             if not self.called:
00061                 print "The bot should send a notification when %s arrives!" % (cmd.__class__.__name__, )
00062                 raise Exception()

Test if appropriate functions are called for (Add|Remove)JIDFromRosterCommand

Definition at line 63 of file test_xmppbot.py.

00063 
00064     def testRosterCommands(self):
00065         """Test if appropriate functions are called for (Add|Remove)JIDFromRosterCommand"""
00066 
00067         command = commands.AddJIDToRosterCommand("dude@example.com")
00068         self.bot.handle_command(command)
00069 
00070         if not self.called:
00071             print "The bot should do something when AddJIDToRosterCommand arrives!"
00072             raise Exception()
00073 
00074         self.called = False
00075         command = commands.RemoveJIDFromRosterCommand("dude@example.com")
00076         self.bot.handle_command(command)
00077 
00078         if not self.called:
00079             print "The bot should do something when RemoveJIDFromRosterCommand arrives!"
00080             raise Exception()


Member Data Documentation

Definition at line 27 of file test_xmppbot.py.

Definition at line 30 of file test_xmppbot.py.

Definition at line 25 of file test_xmppbot.py.

Definition at line 26 of file test_xmppbot.py.


The documentation for this class was generated from the following file: