def test_start_and_stop(on_thread_start):
    # Make sure that if a BMP controller is started, we can stop it immediately
    abc = AsyncBMPController("localhost", on_thread_start=on_thread_start)
    assert abc._stop is False

    abc.stop()
    abc.join()
    assert abc._stop is True

    if on_thread_start is not None:
        on_thread_start.assert_called_once_with()
def abc():
    """Make an AsyncBMPController and stop it at the end."""
    bmp = MockBMP(responses=[SCPVerMessage(0, 0, b"2.1.0")])
    bmp.start()
    async_bmp_controller._SECONDS_BETWEEN_TRIES = 0.1
    abc = AsyncBMPController("localhost")
    yield abc
    print("Stopping")
    abc.stop()
    abc.join()
    print("ABC stopped")
    bmp.stop()
    bmp.join()
    print("BMP Stopped")
def test_start_and_stop(on_thread_start):
    # Make sure that if a BMP controller is started, we can stop it immediately
    bmp = MockBMP(responses=[SCPVerMessage(0, 0, b"2.1.0")])
    bmp.start()
    async_bmp_controller._SECONDS_BETWEEN_TRIES = 0.1
    try:
        abc = AsyncBMPController("localhost", on_thread_start=on_thread_start)
        assert abc._stop is False

        abc.stop()
        abc.join()
        assert abc._stop is True

        if on_thread_start is not None:
            on_thread_start.assert_called_once_with()
    finally:
        bmp.stop()
        bmp.join()
def abc():
    """Make an AsyncBMPController and stop it at the end."""
    abc = AsyncBMPController("localhost")
    yield abc
    abc.stop()
    abc.join()