[Supervisor-checkins] r875 - in supervisor/trunk/src/supervisor: . tests
Mike Naberezny
mike at maintainable.com
Wed May 27 18:15:08 EDT 2009
Author: Mike Naberezny <mike at maintainable.com>
Date: Wed May 27 18:15:07 2009
New Revision: 875
Log:
Added test for states.
Added:
supervisor/trunk/src/supervisor/tests/test_states.py
Modified:
supervisor/trunk/src/supervisor/states.py
Modified: supervisor/trunk/src/supervisor/states.py
==============================================================================
--- supervisor/trunk/src/supervisor/states.py (original)
+++ supervisor/trunk/src/supervisor/states.py Wed May 27 18:15:07 2009
@@ -12,7 +12,7 @@
#
##############################################################################
-# This modules must not depend on any other non-stdlib module to prevent
+# This module must not depend on any other non-stdlib module to prevent
# circular import problems.
class ProcessStates:
Added: supervisor/trunk/src/supervisor/tests/test_states.py
==============================================================================
--- (empty file)
+++ supervisor/trunk/src/supervisor/tests/test_states.py Wed May 27 18:15:07 2009
@@ -0,0 +1,59 @@
+"""Test suite for supervisor.states"""
+
+import unittest
+from StringIO import StringIO
+from supervisor import states
+
+class TopLevelProcessStateTests(unittest.TestCase):
+ def test_module_has_process_states(self):
+ self.assertTrue(hasattr(states, 'ProcessStates'))
+
+ def test_stopped_states_do_not_overlap_with_running_states(self):
+ for state in states.STOPPED_STATES:
+ self.assertFalse(state in states.RUNNING_STATES)
+
+ def test_running_states_do_not_overlap_with_stopped_states(self):
+ for state in states.RUNNING_STATES:
+ self.assertFalse(state in states.STOPPED_STATES)
+
+ def test_getProcessStateDescription_returns_string_when_found(self):
+ state = states.ProcessStates.STARTING
+ self.assertEqual(states.getProcessStateDescription(state),
+ 'STARTING')
+
+ def test_getProcessStateDescription_returns_None_when_not_found(self):
+ self.assertEqual(states.getProcessStateDescription(3.14159),
+ None)
+
+class TopLevelSupervisorStateTests(unittest.TestCase):
+ def test_module_has_supervisor_states(self):
+ self.assertTrue(hasattr(states, 'SupervisorStates'))
+
+ def test_getSupervisorStateDescription_returns_string_when_found(self):
+ state = states.SupervisorStates.RUNNING
+ self.assertEqual(states.getSupervisorStateDescription(state),
+ 'RUNNING')
+
+ def test_getSupervisorStateDescription_returns_None_when_not_found(self):
+ self.assertEqual(states.getSupervisorStateDescription(3.14159),
+ None)
+
+class TopLevelEventListenerStateTests(unittest.TestCase):
+ def test_module_has_eventlistener_states(self):
+ self.assertTrue(hasattr(states, 'EventListenerStates'))
+
+ def test_getEventListenerStateDescription_returns_string_when_found(self):
+ state = states.EventListenerStates.ACKNOWLEDGED
+ self.assertEqual(states.getEventListenerStateDescription(state),
+ 'ACKNOWLEDGED')
+
+ def test_getEventListenerStateDescription_returns_None_when_not_found(self):
+ self.assertEqual(states.getEventListenerStateDescription(3.14159),
+ None)
+
+
+def test_suite():
+ return unittest.findTestCases(sys.modules[__name__])
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
More information about the Supervisor-checkins
mailing list