def test_no_src(): app = MagicMock() eh = AllCodeEventHandler(app) eh._change_dt = datetime(2017, 1, 1) eh.dispatch(Event(src_path=None, dest_path='foo.html')) assert app.src_reload.call_count == 1
def test_no_dest(): app = MagicMock() eh = AllCodeEventHandler(app) eh._change_dt = datetime(2017, 1, 1) class _Event: is_directory = False src_path = 'foobar.jinja' eh.dispatch(_Event()) assert app.src_reload.call_count == 1
def test_move_jet_brains(): app = MagicMock() eh = AllCodeEventHandler(app) eh._change_dt = datetime(2017, 1, 1) eh.dispatch(Event(src_path='foo.___jb_bak___', dest_path='foo.jinja')) assert app.src_reload.call_count == 0
def test_wrong_ext(): app = MagicMock() eh = AllCodeEventHandler(app) eh._change_dt = datetime(2017, 1, 1) eh.dispatch(Event(src_path='foo.jinja_not')) assert app.src_reload.call_count == 0
def test_directory(): app = MagicMock() eh = AllCodeEventHandler(app) eh._change_dt = datetime(2017, 1, 1) eh.dispatch(Event(src_path='foo.jinja', is_directory=True)) assert app.src_reload.call_count == 0
def test_simple(): app = MagicMock() eh = AllCodeEventHandler(app) eh._change_dt = datetime(2017, 1, 1) eh.dispatch(Event(src_path='foo.jinja')) app.src_reload.assert_called_once_with()