コード例 #1
0
def test_start_stop():
    stages = [
        mock.MagicMock(),
        mock.MagicMock(),
        mock.MagicMock(),
    ]
    pipeline = SpeechPipeline(mock.MagicMock(), stages=stages)

    pipeline.start()
    assert pipeline.is_running

    # test second call to start, which ignores if the pipeline is running
    pipeline.start()

    pipeline.step()

    pipeline.close()
    assert not pipeline.is_running
コード例 #2
0
def test_pause_resume():
    stages = [
        mock.MagicMock(),
        mock.MagicMock(),
        mock.MagicMock(),
    ]
    pipeline = SpeechPipeline(mock.MagicMock(), stages=stages)

    pipeline.start()
    assert pipeline.is_running

    pipeline.step()
    pipeline.pause()
    pipeline._input_source.stop.assert_called()

    # verify it does nothing
    pipeline.step()

    pipeline.resume()
    pipeline._input_source.start.assert_called()
    pipeline.close()