Mercurial > enso_core
diff tests/test_command_manager.py @ 28:cff69f571315
Added two unit test suites; one of the tests in one of the suites (for command suggestions) strangely fails at present.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sat, 23 Feb 2008 09:21:00 -0600 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_command_manager.py Sat Feb 23 09:21:00 2008 -0600 @@ -0,0 +1,63 @@ +""" + Tests for the Command Manager. +""" + +# ---------------------------------------------------------------------------- +# Imports +# ---------------------------------------------------------------------------- + +import unittest +import os + +from enso.ui.commands.manager import CommandObjectRegistry +from enso.ui.commands.manager import CommandAlreadyRegisteredError +from enso.ui.commands.interfaces import CommandExpression + + +# ---------------------------------------------------------------------------- +# Object Registry Unit Tests +# ---------------------------------------------------------------------------- + +class FakeCommand: + def __init__( self, name ): + self.name = name + +class RegistryTester( unittest.TestCase ): + def setUp( self ): + self.TESTS = range( ord("a"), ord("z") ) + self.TESTS = [ chr(i) for i in self.TESTS ] + + self.registry = CommandObjectRegistry() + for name in self.TESTS: + expr = CommandExpression( name ) + self.registry.addCommandObj( FakeCommand(name), expr ) + + + def tearDown( self ): + self.registry = None + + def testAlreadyRegistered( self ): + for name in self.TESTS: + expr = CommandExpression( name ) + self.failUnlessRaises( CommandAlreadyRegisteredError, + self.registry.addCommandObj, + FakeCommand(name), expr ) + + def testRegistered( self ): + for name in self.TESTS: + cmd = self.registry.getCommandObj( name ) + self.failUnlessEqual( name, cmd.name ) + + self.failUnlessEqual( set( self.registry.getCommandList() ), + set( self.TESTS ) ) + + # TODO: Match testing. + # TODO: Suggestion testing. + + +# ---------------------------------------------------------------------------- +# Script +# ---------------------------------------------------------------------------- + +if __name__ == "__main__": + unittest.main()