Arjan Scherpenisse avatar Arjan Scherpenisse committed 0be8d14

Some more tests

Comments (0)

Files changed (1)

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.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.