Esempio n. 1
0
def test_dispatch(call, open_mock):
    """normal file event handling"""
    event_handler = EventHandler(lambda: 'foo')
    event_handler.timer = None
    with catch_stdout() as caught_output:
        event_handler.dispatch(MagicMock(src_path='/foo'))
        output = caught_output.getvalue()
    assert output == 'event.src_path /foo\n'
Esempio n. 2
0
    def _watch_and_build(self):
        event_handler = EventHandler(self._build)
        observer = Observer()
        observer.schedule(event_handler, './', recursive=True)
        observer.start()
        try:
            while True:
                time.sleep(1)

        except KeyboardInterrupt:
            observer.stop()
        observer.join()
Esempio n. 3
0
def test_dispatch_directory(call):
    """if event is the main dir we do nothing"""
    event_handler = EventHandler(lambda: 'foo')
    event_handler.dispatch(MagicMock(src_path='./'))
    call.assert_not_called()
Esempio n. 4
0
def test_dispatch_is_ignored(call, open_mock):
    """if git check-ignore passes, we do nothing"""
    call.return_value = 0
    event_handler = EventHandler(lambda: 'foo')
    event_handler.dispatch(MagicMock())
    assert event_handler.timer is None
Esempio n. 5
0
def test_dispatch_git(call):
    """if event relates to git we return immediately"""
    event_handler = EventHandler(lambda: 'foo')
    event_handler.dispatch(MagicMock(src_path='./.git'))
    call.assert_not_called()