From 348de7d7afd900d84d624746366feea04730eacc Mon Sep 17 00:00:00 2001 From: Richard Darst Date: Thu, 24 Sep 2009 20:37:56 +0000 Subject: Added a test of meeting output, and other reorganization - This patch reorganizes some tests, cleans it up. - Also adds test_contents_test, which replays a test meeting and then looks in all outputs to ensure that the specific items appear (or don't appear) in the output files. darcs-hash:20090924203756-82ea9-510faab6775a5ab12baaa3411a47e22a617797e4.gz --- (limited to 'tests') diff --git a/tests/run_test.py b/tests/run_test.py index f4738e2..02cf86c 100644 --- a/tests/run_test.py +++ b/tests/run_test.py @@ -1,15 +1,22 @@ # Richard Darst, 2009 import os +import re import sys import tempfile import unittest +os.environ['MEETBOT_RUNNING_TESTS'] = '1' import meeting import writers running_tests = True -os.environ['MEETBOT_RUNNING_TESTS'] = '1' + +def process_meeting(contents, extraConfig={}): + return meeting.process_meeting(contents=contents, + channel="#none", filename='/dev/null', + dontSave=True, safeMode=False, + extraConfig=extraConfig) class MeetBotTest(unittest.TestCase): @@ -19,7 +26,7 @@ class MeetBotTest(unittest.TestCase): sys.argv[1:] = ["replay", "test-script-1.log.txt"] sys.path.insert(0, "..") try: - execfile("../meeting.py", globals()) + execfile("../meeting.py", {}) finally: del sys.path[0] @@ -56,30 +63,99 @@ class MeetBotTest(unittest.TestCase): '.txt': writers.Text, '.mw': writers.MediaWiki, '.pmw': writers.PmWiki, + #'.tmp.txt|template=+template.txt': writers.Template, + #'.tmp.html|template=+template.html': writers.Template, } 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) + return process_meeting(contents=contents, + extraConfig=extraConfig) 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}) + process_meeting(contents=file('test-script-1.log.txt').read(), + 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}) + # process_meeting(contents=file('test-script-3.log.txt').read(), + # extraConfig={'writer_map':self.full_writer_map}) + + all_commands_test_contents = """ + 10:10:10 #startmeeting + 10:10:10 #topic h6k4orkac + 10:10:10 #info blaoulrao + 10:10:10 #idea alrkkcao4 + 10:10:10 #help ntoircoa5 + 10:10:10 #link http://bnatorkcao.net kroacaonteu + 10:10:10 http://jrotjkor.net krotroun + 10:10:10 #action xrceoukrc + 10:10:10 #nick okbtrokr + + # Should not appear in non-log output + 10:10:10 #idea ckmorkont + 10:10:10 #undo + + # Assert that chairs can change the topic, and non-chairs can't. + 10:10:10 #chair y + 10:10:10 #topic topic_doeschange + 10:10:10 #topic topic_doesntchange + 10:10:10 #unchair y + 10:10:10 #topic topic_doesnt2change + + 10:10:10 #endmeeting + """ + def test_contents_test2(self): + """Ensure that certain input lines do appear in the output. + + This test ensures that the input to certain commands does + appear in the output. + """ + M = process_meeting(contents=self.all_commands_test_contents, + extraConfig={'writer_map':self.full_writer_map}) + results = M.save() + for name, output in results.iteritems(): + self.assert_('h6k4orkac' in output, "Topic failed for %s"%name) + self.assert_('blaoulrao' in output, "Info failed for %s"%name) + self.assert_('alrkkcao4' in output, "Idea failed for %s"%name) + self.assert_('ntoircoa5' in output, "Help failed for %s"%name) + self.assert_('http://bnatorkcao.net' in output, + "Link(1) failed for %s"%name) + self.assert_('kroacaonteu' in output, "Link(2) failed for %s"%name) + self.assert_('http://jrotjkor.net' in output, + "Link detection(1) failed for %s"%name) + self.assert_('krotroun' in output, + "Link detection(2) failed for %s"%name) + self.assert_('xrceoukrc' in output, "Action failed for %s"%name) + self.assert_('okbtrokr' in output, "Nick failed for %s"%name) + + # Things which should only appear or not appear in the + # notes (not the logs): + if 'log' not in name: + self.assert_( 'ckmorkont' not in output, + "Undo failed for %s"%name) + self.assert_('topic_doeschange' in output, + "Chair changing topic failed for %s"%name) + self.assert_('topic_doesntchange' not in output, + "Non-chair not changing topic failed for %s"%name) + self.assert_('topic_doesnt2change' not in output, + "Un-chaired was able to chang topic for %s"%name) + + #def test_contents_test(self): + # contents = open('test-script-3.log.txt').read() + # M = process_meeting(contents=file('test-script-3.log.txt').read(), + # extraConfig={'writer_map':self.full_writer_map}) + # results = M.save() + # for line in contents.split('\n'): + # m = re.search(r'#(\w+)\s+(.*)', line) + # if not m: + # continue + # type_ = m.group(1) + # text = m.group(2) + # text = re.sub('[^\w]+', '', text).lower() + # + # m2 = re.search(t2, re.sub(r'[^\w\n]', '', results['.txt'])) + # import fitz.interactnow + # print m.groups() def t_css(self): """Runs all CSS-related tests. -- cgit v0.9.1