PageRenderTime 24ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/io/test_notify.py

https://bitbucket.org/prologic/circuits/
Python | 41 lines | 25 code | 15 blank | 1 comment | 0 complexity | ea14c7be8f772fe12d67718838c4dd54 MD5 | raw file
  1. #!/usr/bin/env python
  2. import pytest
  3. pytest.importorskip("pyinotify")
  4. from circuits.io.notify import Notify
  5. from circuits import Component, handler
  6. class App(Component):
  7. def init(self, *args, **kwargs):
  8. self.created = False
  9. @handler('created', channel='notify')
  10. def created(self, *args, **kwargs):
  11. self.created = True
  12. def test_notify(manager, watcher, tmpdir):
  13. app = App().register(manager)
  14. notify = Notify().register(app)
  15. watcher.wait("registered")
  16. notify.add_path(str(tmpdir))
  17. tmpdir.ensure("helloworld.txt")
  18. watcher.wait("created")
  19. assert app.created
  20. app.created = False
  21. notify.remove_path(str(tmpdir))
  22. tmpdir.ensure("helloworld2.txt")
  23. watcher.wait("created")
  24. assert not app.created
  25. app.unregister()
  26. watcher.wait("unregistered")