Example #1
0
def test_event_descriptor_insertion():
    # format some data keys for insertion
    data_keys = {'some_value': {'source': 'PV:pv1',
                                'shape': [1, 2],
                                'dtype': 'array'},
                 'some_other_val': {'source': 'PV:pv2',
                                    'shape': [],
                                    'dtype': 'number'},
                 'data_key3': {'source': 'PV:pv1',
                               'shape': [],
                               'dtype': 'number',
                               'external': 'FS:foobar'}}
    time = ttime.time()
    # test insert
    ev_desc_uid = mdsc.insert_descriptor(run_start_uid, data_keys, time,
                                         str(uuid.uuid4()))
    ev_desc_mds, = mdsc.find_descriptors(uid=ev_desc_uid)
    # make sure the sanitized event descriptor has no uid
    check_for_id(ev_desc_mds)

    # make sure the event descriptor is pointing to the correct run start
    referenced_run_start = ev_desc_mds['run_start']
    assert_equal(referenced_run_start.uid, run_start_uid)
    assert_equal(ev_desc_mds['time'], time)

    for k in data_keys:
        for ik in data_keys[k]:
            assert_equal(ev_desc_mds.data_keys[k][ik],
                         data_keys[k][ik])
Example #2
0
def setup_syn(custom=None):
    if custom is None:
        custom = {}
    data_keys = {
        k: {
            'source': k,
            'dtype': 'number',
            'shape': None
        }
        for k in 'ABCEDEFGHIJKL'
    }
    scan_id = 1

    # Create a BeginRunEvent that serves as entry point for a run
    rs = mdsc.insert_run_start(scan_id=scan_id,
                               beamline_id='testing',
                               time=ttime.time(),
                               custom=custom,
                               uid=str(uuid.uuid4()))

    # Create an EventDescriptor that indicates the data
    # keys and serves as header for set of Event(s)
    e_desc = mdsc.insert_descriptor(data_keys=data_keys,
                                    time=ttime.time(),
                                    run_start=rs,
                                    uid=str(uuid.uuid4()))
    return rs, e_desc, data_keys
Example #3
0
def test_bad_event_desc():
 
    data_keys = {k:  {'source': k,
                      'dtype': 'number',
                      'shape': None} for k in ['foo', 'foo.bar']
                 }
    scan_id = 1
 
    # Create a BeginRunEvent that serves as entry point for a run
    rs = mdsc.insert_run_start(scan_id=scan_id, beamline_id='testing',
                              time=ttime.time(),
                              uid=str(uuid.uuid4()))
 
    # Create an EventDescriptor that indicates the data
    # keys and serves as header for set of Event(s)
    mdsc.insert_descriptor(data_keys=data_keys,
                           time=ttime.time(),
                           run_start=rs, uid=str(uuid.uuid4()))
Example #4
0
def test_bad_event_desc():

    data_keys = {
        k: {
            'source': k,
            'dtype': 'number',
            'shape': None
        }
        for k in ['foo', 'foo.bar']
    }
    scan_id = 1

    # Create a BeginRunEvent that serves as entry point for a run
    rs = mdsc.insert_run_start(scan_id=scan_id,
                               beamline_id='testing',
                               time=ttime.time(),
                               uid=str(uuid.uuid4()))

    # Create an EventDescriptor that indicates the data
    # keys and serves as header for set of Event(s)
    mdsc.insert_descriptor(data_keys=data_keys,
                           time=ttime.time(),
                           run_start=rs,
                           uid=str(uuid.uuid4()))
Example #5
0
def setup_syn(custom=None):
    if custom is None:
        custom = {}
    data_keys = {k: {'source': k,
                     'dtype': 'number',
                     'shape': None} for k in 'ABCEDEFGHIJKL'
                 }
    scan_id = 1

    # Create a BeginRunEvent that serves as entry point for a run
    rs = mdsc.insert_run_start(scan_id=scan_id, beamline_id='testing',
                               time=ttime.time(),
                               custom=custom, uid=str(uuid.uuid4()))

    # Create an EventDescriptor that indicates the data
    # keys and serves as header for set of Event(s)
    e_desc = mdsc.insert_descriptor(data_keys=data_keys,
                                    time=ttime.time(),
                                    run_start=rs, uid=str(uuid.uuid4()))
    return rs, e_desc, data_keys
Example #6
0
def test_event_descriptor_insertion():
    # format some data keys for insertion
    data_keys = {
        'some_value': {
            'source': 'PV:pv1',
            'shape': [1, 2],
            'dtype': 'array'
        },
        'some_other_val': {
            'source': 'PV:pv2',
            'shape': [],
            'dtype': 'number'
        },
        'data_key3': {
            'source': 'PV:pv1',
            'shape': [],
            'dtype': 'number',
            'external': 'FS:foobar'
        }
    }
    time = ttime.time()
    # test insert
    ev_desc_uid = mdsc.insert_descriptor(run_start_uid, data_keys, time,
                                         str(uuid.uuid4()))
    ev_desc_mds, = mdsc.find_descriptors(uid=ev_desc_uid)
    # make sure the sanitized event descriptor has no uid
    check_for_id(ev_desc_mds)

    # make sure the event descriptor is pointing to the correct run start
    referenced_run_start = ev_desc_mds['run_start']
    assert_equal(referenced_run_start.uid, run_start_uid)
    assert_equal(ev_desc_mds['time'], time)

    for k in data_keys:
        for ik in data_keys[k]:
            assert_equal(ev_desc_mds.data_keys[k][ik], data_keys[k][ik])