source: trunk/game/tests/test_console.py @ 281

Revision 281, 1011 bytes checked in by Kaydeth_parpg, 10 years ago (diff)

Ticket: #94: Patch by amo-ej1. "grid" console command added to display a grid overlay on the map. Console command logic moved to it's own class (console.py). Also unit tests added for console class. fixes[s:trac, t:94]

Line 
1import unittest
2from scripts.console import Console
3
4class test_console(unittest.TestCase):
5    def setUp(self):
6        self.con=Console(None)
7        self.invalString="Invalid command, enter help for more information"
8        pass
9   
10    def tearDown(self):
11        pass 
12
13    def testConsoleCommandHelp(self):
14        """ Test the help console command """
15       
16        self.assertNotEqual(self.con.handleHelp("help"),self.invalString)
17        self.assertNotEqual(self.con.handleConsoleCommand("help"),
18                            self.invalString)
19
20    def testConsoleCommandPython(self):
21        """ Test the python console command """ 
22        self.assertEqual(self.con.handlePython("python 1+1"),"2")
23        self.assertEqual(self.con.handleConsoleCommand("python 1+1"),"2")
24       
25    def testInvalid(self):
26        """Test an invalid console command """
27
28        self.assertEqual(self.con.handleConsoleCommand("invalid"),
29                         self.invalString)
30
Note: See TracBrowser for help on using the repository browser.