Esempio n. 1
0
def test_wait_for_stores_complete_success(daq_store_client):
    """Make sure the wait_for_stores_complete function can succeed correctly"""
    state = RequestState()
    store_helper = DataAcquisitionStoreHelper(daq_store_client, state)
    assert state._status_proto.status != state._status_proto.STATUS_COMPLETE
    store_helper.wait_for_stores_complete()
    store_helper.state.set_complete_if_no_error()
    assert state._status_proto.status == state._status_proto.STATUS_COMPLETE

    state = RequestState()
    store_helper = DataAcquisitionStoreHelper(daq_store_client, state)
    pool = ThreadPoolExecutor(max_workers=1)

    data_id = data_acquisition_pb2.DataIdentifier()
    data_id.action_id.group_name = 'A'
    data_id.action_id.action_name = 'B'
    data_id.channel = 'test_channel'
    image_capture = image_pb2.ImageCapture()
    store_helper.store_image(image_capture, data_id)

    assert state._status_proto.status != state._status_proto.STATUS_COMPLETE
    store_helper.wait_for_stores_complete()
    store_helper.state.set_complete_if_no_error()
    assert state._status_proto.status == state._status_proto.STATUS_COMPLETE
Esempio n. 2
0
def test_wait_for_stores_complete_failure(daq_store_failure_client):
    """Make sure the wait_for_stores_complete function can fail correctly"""
    state = RequestState()
    store_helper = DataAcquisitionStoreHelper(daq_store_failure_client, state)

    data_id = data_acquisition_pb2.DataIdentifier()
    data_id.action_id.group_name = 'A'
    data_id.action_id.action_name = 'B'
    data_id.channel = 'test_channel'
    image_capture = image_pb2.ImageCapture()
    store_helper.store_image(image_capture, data_id)

    store_helper.wait_for_stores_complete()
    assert state._status_proto.status == state._status_proto.STATUS_DATA_ERROR
    assert state._status_proto.data_errors[0].data_id == data_id
Esempio n. 3
0
def test_wait_for_stores_complete_cancel(daq_store_client):
    """Make sure the wait_for_stores_complete function can cancel correctly"""
    state = RequestState()
    store_helper = DataAcquisitionStoreHelper(daq_store_client, state)

    data_id = data_acquisition_pb2.DataIdentifier()
    data_id.action_id.group_name = 'A'
    data_id.action_id.action_name = 'B'
    data_id.channel = 'test_channel'
    image_capture = image_pb2.ImageCapture()
    store_helper.store_image(image_capture, data_id)

    with state._lock:
        state._cancelled = True
    with pytest.raises(RequestCancelledError):
        store_helper.wait_for_stores_complete()