# Richard Darst, 2009 import os import sys import tempfile import unittest import meeting import writers running_tests = True os.environ['MEETBOT_RUNNING_TESTS'] = '1' class MeetBotTest(unittest.TestCase): def test_replay(self): """Replay of a meeting, using __meeting__. """ sys.argv[1:] = ["replay", "test-script-1.log.txt"] sys.path.insert(0, "..") try: execfile("../meeting.py", globals()) finally: del sys.path[0] def test_supybottests(self): """Test by sending input to supybot, check responses. Uses the external supybot-test command. Unfortunantly, that doesn't have a useful status code, so I need to parse the output. """ os.symlink("..", "MeetBot") try: output = os.popen("supybot-test ./MeetBot 2>&1").read() print output assert 'FAILED' not in output, "supybot-based tests failed." assert '\nOK\n' in output, "supybot-based tests failed." finally: os.unlink("MeetBot") trivial_contents = """ 10:10:10 #startmeeting 10:10:10 blah 10:10:10 #endmeeting """ full_writer_map = { '.log.txt': writers.TextLog, '.log.1.html': writers.HTMLlog1, '.log.html': writers.HTMLlog2, '.1.html': writers.HTML1, '.html': writers.HTML2, '.rst': writers.ReST, '.rst.html': writers.HTMLfromReST, '.txt': writers.Text, } def M_trivial(self, contents=None, extraConfig={}): if contents is None: contents = self.trivial_contents return meeting.process_meeting(contents=contents, channel="#none", filename='/dev/null', dontSave=True, extraConfig=extraConfig, safeMode=False) def test_script_1(self): meeting.process_meeting(contents=file('test-script-1.log.txt').read(), channel="#none", filename='/dev/null', dontSave=True, safeMode=False, extraConfig={ 'writer_map':self.full_writer_map}) #def test_script_3(self): # meeting.process_meeting(contents=file('test-script-3.log.txt').read(), # channel="#none", filename='/dev/null', # dontSave=True, safeMode=False, # extraConfig={ # 'writer_map':self.full_writer_map}) def t_css(self): """Runs all CSS-related tests. """ self.test_css_embed() self.test_css_noembed() self.test_css_file_embed() self.test_css_file() self.test_css_none() def test_css_embed(self): extraConfig={ } results = self.M_trivial(extraConfig={}).save() self.assert_('