diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2019-03-27 09:29:27 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2019-03-27 09:29:27 -0400 |
commit | 8e1325d97ffc9d84f9d757ab99ae1a291df24b8e (patch) | |
tree | 72daf34137a6321fa5659b6a859f17dfde30d1d5 | |
parent | 5ddee992174b183ebe33d1f74b37c1510372cb7e (diff) | |
download | cherrypy-git-8e1325d97ffc9d84f9d757ab99ae1a291df24b8e.tar.gz |
Add test capturing expectation that 'wait' will publish periodically to 'channel'.
-rw-r--r-- | cherrypy/test/test_bus.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/cherrypy/test/test_bus.py b/cherrypy/test/test_bus.py index 922a8b24..12a516c9 100644 --- a/cherrypy/test/test_bus.py +++ b/cherrypy/test/test_bus.py @@ -1,6 +1,6 @@ import threading import time -import unittest +import unittest.mock from cherrypy.process import wspbus @@ -194,6 +194,18 @@ class BusMethodTests(unittest.TestCase): if b.state not in states: self.fail('State %r not in %r' % (b.state, states)) + def test_wait_publishes_periodically(self): + bus = wspbus.Bus() + callback = unittest.mock.MagicMock() + bus.subscribe('main', callback) + + def set_start(): + time.sleep(0.05) + bus.start() + threading.Thread(target=set_start).start() + bus.wait(bus.states.STARTED, interval=0.01, channel='main') + assert callback.call_count > 3 + def test_block(self): b = wspbus.Bus() self.log(b) |