@mock.patch('anacode.api.client.AnacodeClient.analyze', time_consuming)
def test_parallel_queries(api, mocker):
    text = ['安全性能很好，很帅气。']
    writer = writers.DataFrameWriter()
    writer.init()
    mocker.spy(api, 'analyze')
    analyzer = client.Analyzer(api, writer, threads=4, bulk_size=4)
    start = time.time()
    with analyzer:
        for _ in range(4):
            analyzer.analyze(text, ['categories'])
    stop = time.time()
    duration = (stop - start)
    assert (abs((duration - 0.1)) < 0.1)
@mock.patch('anacode.api.client.AnacodeClient.analyze', time_consuming)
def test_parallel_queries(api, mocker):
    text = ['安全性能很好，很帅气。']
    writer = writers.DataFrameWriter()
    writer.init()
    mocker.spy(api, 'analyze')
    analyzer = client.Analyzer(api, writer, threads=4, bulk_size=4)
    start = time.time()
    with analyzer:
        for _ in range(4):
            analyzer.analyze(text, ['categories'])
    stop = time.time()
    duration = (stop - start)
    assert (abs((duration - 0.1)) < 0.1)