[py-svn] r57149 - in py/branch/event/py/test2/dist: . testing

hpk at codespeak.net hpk at codespeak.net
Sat Aug 9 20:20:29 CEST 2008


Author: hpk
Date: Sat Aug  9 20:20:29 2008
New Revision: 57149

Modified:
   py/branch/event/py/test2/dist/hostmanage.py
   py/branch/event/py/test2/dist/testing/test_hostmanage.py
Log:
fix and test setting of notification hook.


Modified: py/branch/event/py/test2/dist/hostmanage.py
==============================================================================
--- py/branch/event/py/test2/dist/hostmanage.py	(original)
+++ py/branch/event/py/test2/dist/hostmanage.py	Sat Aug  9 20:20:29 2008
@@ -154,12 +154,12 @@
 
     def setup_hosts(self, notify=None):
         if notify is None:
-            self.notify = self.session.bus.notify
+            notify = self.session.bus.notify
         self.init_rsync()
         for host in self.hosts:
             host.node = MasterNode(host, 
                                    self.session.config, 
-                                   self.session.bus.notify)
+                                   notify)
 
     def wait_for_completion(self, maxtimeout=2.0):
         self.queue = py.std.Queue.Queue()

Modified: py/branch/event/py/test2/dist/testing/test_hostmanage.py
==============================================================================
--- py/branch/event/py/test2/dist/testing/test_hostmanage.py	(original)
+++ py/branch/event/py/test2/dist/testing/test_hostmanage.py	Sat Aug  9 20:20:29 2008
@@ -256,6 +256,18 @@
             assert host.gw_remotepath is None
             assert not host.relpath 
 
+    def test_hostmanage_setup_hosts(self):
+        hosts = [Host("localhost") for i in range(3)]
+        session = py.test2.config._reparse([self.source]).initsession()
+        hm = HostManager(session, hosts=hosts)
+        queue = py.std.Queue.Queue()
+        hm.setup_hosts(notify=queue.put)
+        for host in hm.hosts:
+            host.node.shutdown()
+        for host in hm.hosts:
+            event = queue.get(timeout=2.0)
+            assert isinstance(event, repevent.HostDown)
+
     def XXXtest_ssh_rsync_samehost_twice(self):
         #XXX we have no easy way to have a temp directory remotely!
         option = py.test2.config.option



More information about the pytest-commit mailing list