Commits

Arjan Scherpenisse  committed 0be8d14

Some more tests

  • Participants
  • Parent commits ab96234

Comments (0)

Files changed (1)

File sparked/test/test_monitor.py

     pass
 
 
+class StatefulMonitor(monitors.Monitor):
+    def __init__(self, ok):
+        self.ok = ok
+
+
+
 class TestMonitorContainer(unittest.TestCase):
     """
     Test the L{sparked.monitors.MonitorContainer}
         self.assertEquals(c.monitors, [])
 
 
+
+    def testContainerState(self):
+        c = monitors.MonitorContainer()
+
+        self.assertEquals(True, c.ok)
+        self.assertEquals((), c.state)
+
+        c.addMonitor(StatefulMonitor(True))
+        self.assertEquals(True, c.ok)
+        self.assertEquals((True,), c.state)
+
+        c.addMonitor(StatefulMonitor(False))
+        self.assertEquals(False, c.ok)
+        self.assertEquals((True, False), c.state)
+
+
+    def testContainerStateNone(self):
+        c = monitors.MonitorContainer()
+        c.addMonitor(StatefulMonitor(None))
+        self.assertEquals(True, c.ok)
+        self.assertEquals((None,), c.state)
+
+
     def testSignals(self):
         """
         Whether the "updated" signal comes in when a monitor changes state.