Back to index

python-cliapp  1.20120630
plugin_tests.py
Go to the documentation of this file.
00001 # Copyright (C) 2009-2012  Lars Wirzenius
00002 # 
00003 # This program is free software; you can redistribute it and/or modify
00004 # it under the terms of the GNU General Public License as published by
00005 # the Free Software Foundation; either version 2 of the License, or
00006 # (at your option) any later version.
00007 # 
00008 # This program is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 # GNU General Public License for more details.
00012 # 
00013 # You should have received a copy of the GNU General Public License along
00014 # with this program; if not, write to the Free Software Foundation, Inc.,
00015 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016 
00017 
00018 import unittest
00019 
00020 from cliapp import Plugin
00021 
00022 
00023 class PluginTests(unittest.TestCase):
00024 
00025     def setUp(self):
00026         self.plugin = Plugin()
00027         
00028     def test_name_is_class_name(self):
00029         self.assertEqual(self.plugin.name, 'Plugin')
00030 
00031     def test_description_is_empty_string(self):
00032         self.assertEqual(self.plugin.description, '')
00033 
00034     def test_version_is_zeroes(self):
00035         self.assertEqual(self.plugin.version, '0.0.0')
00036 
00037     def test_required_application_version_is_zeroes(self):
00038         self.assertEqual(self.plugin.required_application_version, '0.0.0')
00039 
00040     def test_enable_raises_exception(self):
00041         self.assertRaises(Exception, self.plugin.enable)
00042 
00043     def test_disable_raises_exception(self):
00044         self.assertRaises(Exception, self.plugin.disable)
00045 
00046     def test_enable_wrapper_calls_enable(self):
00047         self.plugin.enable = lambda: setattr(self, 'enabled', True)
00048         self.plugin.enable_wrapper()
00049         self.assert_(self.enabled, True)
00050 
00051     def test_disable_wrapper_calls_disable(self):
00052         self.plugin.disable = lambda: setattr(self, 'disabled', True)
00053         self.plugin.disable_wrapper()
00054         self.assert_(self.disabled, True)
00055