Ejemplo n.º 1
0
def test_logger():
    # Start our test service
    p = multiprocessing.Process(target=main)
    p.start()
    time.sleep(.2)  # Give it time to start

    c = SynClient()
    c.subscribe('log.logger*')

    cs = CellaservProxy()
    cs.logger.do_log()  # Send request
    time.sleep(.2)  # Give it time to crash

    # Ensure that we have our 4 log messages
    for _ in range(4):
        assert c.read_message().type == Message.Publish

    p.terminate()
Ejemplo n.º 2
0
def test_basic():
    c = SynClient()

    c.subscribe('log.coding-error')

    # Setup our client to timeout when there no message is recv
    c._socket.settimeout(.1)

    # Send good publish
    c.publish(event='foo', data=json.dumps({'a': '0'}).encode())
    assert not recv(c)

    # Internal error
    c.publish(event='foo', data=json.dumps({'a': 'hello'}).encode())
    assert recv(c)

    # Bad publish args
    c.publish(event='foo', data=json.dumps({'b': '0'}).encode())
    assert recv(c)