Example #1
0
def test_event_handler_two_clients(logcap):
    logcap.set_logger('dev_server', logging.INFO)
    app = {WS: [MockWS(), MockWS()]}
    hdl = DevServerEventEventHandler(app, 'foobar')
    event = FileSystemEvent('foobar/whatever.js')
    hdl.on_any_event(event)
    assert logcap.log == 'prompting reload of whatever.js on 2 clients\n'
Example #2
0
def test_event_handler_one_client(logcap):
    logcap.set_logger('dev_server', logging.INFO)
    app = {WS: [MockWS()]}
    hdl = DevServerEventEventHandler(app, 'foobar')
    event = FileSystemEvent('foobar/whatever.js')
    hdl.on_any_event(event)
    ws = app[WS][0]
    assert len(ws.sent_strs) == 1
    data = json.loads(ws.sent_strs[0])
    assert data == {'liveCSS': True, 'path': 'whatever.js', 'command': 'reload', 'liveImg': True}
    assert logcap.log == 'prompting reload of whatever.js on 1 client\n'