示例#1
0
def test_wait_condition_negate(delay, timeout, result):
    """
    Test the negated `wait_agent_condition` function.
    """
    kid = SugarAddict()
    Timer(delay, kid.feed_candy).start()
    assert wait_condition(kid.sad, negate=True, timeout=timeout) == result
示例#2
0
def test_wait_condition_negate(delay, timeout, result):
    """
    Test the negated `wait_agent_condition` function.
    """
    kid = SugarAddict()
    Timer(delay, kid.feed_candy).start()
    assert wait_condition(kid.sad, negate=True, timeout=timeout) == result
示例#3
0
def test_wait_condition(delay, timeout, result):
    """
    Test the `wait_agent_condition` function.
    """
    kid = SugarAddict()
    Timer(delay, kid.feed_candy).start()
    assert wait_condition(kid.happy, timeout=timeout) == result
示例#4
0
def test_wait_condition(delay, timeout, result):
    """
    Test the `wait_agent_condition` function.
    """
    kid = SugarAddict()
    Timer(delay, kid.feed_candy).start()
    assert wait_condition(kid.happy, timeout=timeout) == result
示例#5
0
def test_agent_close_ipc_socket_nameserver_shutdown():
    """
    Check that the socket is closed and the socket file removed after the name
    server is shut down.
    """
    ns = run_nameserver()
    agent = run_agent('agent')
    addr = agent.bind('PUSH', 'main')
    ns.shutdown()

    assert wait_condition(addr.address.exists, negate=True)
示例#6
0
def test_agent_close_ipc_socket_agent_kill(nsproxy):
    """
    Check that the socket is closed and the socket file removed after the agent
    is killed.
    """
    agent = run_agent('name')
    address = agent.bind('PUSH')
    agent.oneway.kill()

    assert agent_dies('name', nsproxy)
    assert wait_condition(address.address.exists, negate=True)
示例#7
0
def test_agent_close_ipc_socket_nameserver_shutdown():
    """
    Check that the socket is closed and the socket file removed after the name
    server is shut down.
    """
    ns = run_nameserver()
    agent = run_agent('agent')
    addr = agent.bind('PUSH', 'main')
    ns.shutdown()

    assert wait_condition(addr.address.exists, negate=True)
示例#8
0
def test_agent_close_ipc_socket_agent_kill(nsproxy):
    """
    Check that the socket is closed and the socket file removed after the agent
    is killed.
    """
    agent = run_agent('name')
    address = agent.bind('PUSH')
    agent.oneway.kill()

    assert agent_dies('name', nsproxy)
    assert wait_condition(address.address.exists, negate=True)
示例#9
0
def test_agent_close_ipc_socket_agent_crash_nameserver_shutdown():
    """
    Check that the socket is closed and the socket file removed after the agent
    crashes and the name server calls for shutdown.
    """
    ns = run_nameserver()
    agent = run_agent('agent')
    addr = agent.bind('PUSH', 'main')
    with pytest.raises(RuntimeError):
        agent.raise_exception()

    ns.shutdown()

    assert wait_condition(addr.address.exists, negate=True)
示例#10
0
def test_agent_close_ipc_socket_agent_crash_nameserver_shutdown():
    """
    Check that the socket is closed and the socket file removed after the agent
    crashes and the name server calls for shutdown.
    """
    ns = run_nameserver()
    agent = run_agent('agent')
    addr = agent.bind('PUSH', 'main')
    with pytest.raises(RuntimeError):
        agent.raise_exception()

    ns.shutdown()

    assert wait_condition(addr.address.exists, negate=True)
示例#11
0
def test_agent_close_ipc_socket_agent_blocked_nameserver_shutdown():
    """
    Check that the socket is closed and the socket file removed when the name
    server is shut down having a blocked agent.
    """
    def block(agent):
        agent.send('out', 'blocking...')

    ns = run_nameserver()
    blocker = run_agent('blocker')
    blocker.set_method(block)
    addr = blocker.bind('PUSH', alias='out')
    blocker.after(0, 'block')
    ns.shutdown(timeout=1.)

    assert wait_condition(addr.address.exists, negate=True)
示例#12
0
def test_agent_close_ipc_socket_agent_blocked_nameserver_shutdown():
    """
    Check that the socket is closed and the socket file removed when the name
    server is shut down having a blocked agent.
    """
    def block(agent):
        agent.send('out', 'blocking...')

    ns = run_nameserver()
    blocker = run_agent('blocker')
    blocker.set_method(block)
    addr = blocker.bind('PUSH', alias='out')
    blocker.after(0, 'block')
    ns.shutdown(timeout=1.)

    assert wait_condition(addr.address.exists, negate=True)