Commits

Marc-Alexandre Chan committed 5726a58

added some test code for manual testing

Comments (0)

Files changed (6)

 syntax: glob
 *.pyc
+minibot/config/**.ini
+minibot/test/temp/*

minibot/DailyPrompt-minibot.psproj

 Name=config
 
 [Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node0]
+ClassName=TProjectFolderNode
+Name=localtest
+
+[Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node0]
+ClassName=TProjectFileNode
+FileName=$[Project-Path]config\localtest\minibot.ini
+
+[Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node0\ChildNodes]
+Count=1
+
+[Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes\Node1]
 ClassName=TProjectFileNode
 FileName=$[Project-Path]minibot.ini.default
 
 [Project\ChildNodes\Node0\ChildNodes\Node0\ChildNodes]
-Count=1
+Count=2
 
 [Project\ChildNodes\Node0\ChildNodes\Node1]
 ClassName=TProjectFolderNode
 
 [Project\ChildNodes\Node0\ChildNodes\Node2]
 ClassName=TProjectFolderNode
+Name=scripts
+
+[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node0]
+ClassName=TProjectFileNode
+FileName=D:\Projects\Software\DailyPrompt\minibot.py
+
+[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node1]
+ClassName=TProjectFileNode
+FileName=D:\Projects\Software\DailyPrompt\minibotd.py
+
+[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes]
+Count=2
+
+[Project\ChildNodes\Node0\ChildNodes\Node3]
+ClassName=TProjectFolderNode
 Name=test
 
-[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node0]
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node0]
 ClassName=TProjectFolderNode
 Name=mock
 
-[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node1]
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node0\ChildNodes\Node0]
+ClassName=TProjectFileNode
+FileName=$[Project-Path]test\mock\reddit.py
+
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node0\ChildNodes]
+Count=1
+
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node1]
 ClassName=TProjectFileNode
 FileName=$[Project-Path]test\__init__.py
 
-[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node2]
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node2]
 ClassName=TProjectFileNode
 FileName=$[Project-Path]test\blank.ini
 
-[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node3]
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node3]
 ClassName=TProjectFileNode
 FileName=$[Project-Path]test\config.ini
 
-[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node4]
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node4]
 ClassName=TProjectFileNode
 FileName=$[Project-Path]test\config.py
 
-[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node5]
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node5]
 ClassName=TProjectFileNode
 FileName=$[Project-Path]test\db.py
 
-[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node6]
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node6]
 ClassName=TProjectFileNode
 FileName=$[Project-Path]test\events.py
 
-[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node7]
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node7]
 ClassName=TProjectFileNode
 FileName=$[Project-Path]test\eventscheduler.py
 
-[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node8]
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node8]
 ClassName=TProjectFileNode
 FileName=$[Project-Path]test\init.py
 
-[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node9]
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node9]
 ClassName=TProjectFileNode
 FileName=$[Project-Path]test\test.py
 
-[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node10]
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node10]
 ClassName=TProjectFileNode
 FileName=$[Project-Path]test\test.py
 
-[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes\Node11]
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes\Node11]
 ClassName=TProjectFileNode
 FileName=$[Project-Path]test\util.py
 
-[Project\ChildNodes\Node0\ChildNodes\Node2\ChildNodes]
+[Project\ChildNodes\Node0\ChildNodes\Node3\ChildNodes]
 Count=12
 
-[Project\ChildNodes\Node0\ChildNodes\Node3]
-ClassName=TProjectFileNode
-FileName=$[Project-Path]../minibot.py
-
 [Project\ChildNodes\Node0\ChildNodes\Node4]
 ClassName=TProjectFileNode
 FileName=$[Project-Path]__init__.py

minibot/config/localtest/__init__.py

+

minibot/config/localtest/minibot-setup.py

+# -*- coding: utf-8 -*-
+#-------------------------------------------------------------------------------
+# The Daily Prompt Mini-Bot - A Shut Up and Write Project
+# Miscellaneous Utilities
+# Author: Marc-Alexandre Chan <laogeodritt at arenthil.net>
+#-------------------------------------------------------------------------------
+#
+# Copyright (c) 2012 Marc-Alexandre Chan. Licensed under the GNU GPL version 3
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#-------------------------------------------------------------------------------
+
+import sys
+from os.path import dirname, abspath
+from os import chdir
+
+try:
+    current_script = __file__
+except NameError:
+    import inspect
+    current_script = inspect.getfile(inspect.currentframe())
+
+botroot = abspath(dirname(dirname(dirname(dirname(current_script)))))
+chdir(botroot)
+sys.path.append(botroot)
+
+from minibot import DailyPromptMinibot
+
+bot = DailyPromptMinibot('minibot/config/localtest/minibot.ini')
+
+config = bot.config
+log = bot.logger
+reddit = bot.reddit
+scheduler = bot.scheduler
+db = bot.db
+dbs = db.get_new_session()
+
+class SchedulerMock(object):
+    def __init__(self):
+        self.events = []
+        self.last_event = None
+
+    def queue_event(self, event):
+        self.last_event = event
+        self.events.append(event)
+
+    def print_event(index=-1):
+        print repr(self.events[index])

minibot/config/localtest/notes.txt

+>>> execfile('D:\Projects\Software\DailyPrompt\minibot\config\localtest\minibot-setup.py')
+>>> import minibot.events
+>>> ev=minibot.events.PromptCommandBase
+>>> ev=ev(1, title='title', text='text')
+>>> res = {'reddit' : reddit, 'dbsession' : db.get_new_session(), 'config.minibot' : config.minibot, 'logger' : log}
+>>> ev.res = res
+>>> 

minibot/test/events.py

 # modules used in test code
 import sys
 
-@unittest.skip('Not Implemented')
-class TestEvents(unittest.TestCase):
+@unittest.skip("Incomplete test")
+class TestCheckMessageEvent(unittest.TestCase):
     def setUp(self):
         # mocks and objects
         self.res = {
 
         # calls for mocking
         #reddit.user.get_unread(limit=self.msg_chunk)
+        #reddit.user.name
 
         #owner.queue_event(event_obj)
 
-
     def tearDown(self):
         pass
 
+    def runTest(self):
+        pass
+
+    def run(self):
+        pass
+
+    def _process_message(self):
+        # trivial method tests not implemented
+        pass
+
+    def _is_valid_message(self):
+        pass
+
+    def _send_error_reply(self):
+        # trivial method tests not implemented
+        pass
+
+    def _parse_message(self):
+        pass
+
+    def _parse_field(self):
+        pass
+
+    def _make_command(self):
+        pass
+
+    def handle_exception(self):
+        self.assertFalse(self.cmd.handle_exception())
+
+    def _exc_msg_data(self):
+        # trivial method tests not implemented
+        pass
+
+    # TODO: remove this
     def testCheckMessageEvent(self):
         pass
         # calls/accesses for mocking