PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/io/test_notify.py

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