Ejemplo n.º 1
0
def test_find_run_start():
    run_start_uid, e_desc_uid, data_keys = setup_syn()
    mdsc.insert_run_stop(run_start_uid, ttime.time(), uid=str(uuid.uuid4()))

    run_start = mdsc.run_start_given_uid(run_start_uid)

    run_start2, = list(mdsc.find_run_starts(uid=run_start_uid))

    assert_equal(run_start, run_start2)
Ejemplo n.º 2
0
def test_find_run_start():
    run_start_uid, e_desc_uid, data_keys = setup_syn()
    mdsc.insert_run_stop(run_start_uid, ttime.time(), uid=str(uuid.uuid4()))

    run_start = mdsc.run_start_given_uid(run_start_uid)

    run_start2, = list(mdsc.find_run_starts(uid=run_start_uid))

    assert_equal(run_start, run_start2)
Ejemplo n.º 3
0
def test_insert_run_start():
    time = ttime.time()
    beamline_id = "sample_beamline"
    scan_id = 42
    custom = {"foo": "bar", "baz": 42, "aardvark": ["ants", 3.14]}
    run_start_uid = mdsc.insert_run_start(
        time, beamline_id=beamline_id, scan_id=scan_id, custom=custom, uid=str(uuid.uuid4())
    )

    run_start_mds, = mdsc.find_run_starts(uid=run_start_uid)

    names = ["time", "beamline_id", "scan_id"] + list(custom.keys())
    values = [time, beamline_id, scan_id] + list(custom.values())

    for name, val in zip(names, values):
        assert_equal(getattr(run_start_mds, name), val)

    # make sure the metadatstore document raises properly
    check_for_id(run_start_mds)
Ejemplo n.º 4
0
def test_insert_run_start():
    time = ttime.time()
    beamline_id = 'sample_beamline'
    scan_id = 42
    custom = {'foo': 'bar', 'baz': 42, 'aardvark': ['ants', 3.14]}
    run_start_uid = mdsc.insert_run_start(time,
                                          beamline_id=beamline_id,
                                          scan_id=scan_id,
                                          custom=custom,
                                          uid=str(uuid.uuid4()))

    run_start_mds, = mdsc.find_run_starts(uid=run_start_uid)

    names = ['time', 'beamline_id', 'scan_id'] + list(custom.keys())
    values = [time, beamline_id, scan_id] + list(custom.values())

    for name, val in zip(names, values):
        assert_equal(getattr(run_start_mds, name), val)

    # make sure the metadatstore document raises properly
    check_for_id(run_start_mds)
Ejemplo n.º 5
0
def test_find_funcs_for_smoke():
    rs, = mdsc.find_run_starts(uid=run_start_uid)
    test_dict = {
        mdsc.find_run_starts: [
            {"limit": 5},
            {"start_time": ttime.time()},
            {"start_time": "2015"},
            {"start_time": "2015-03-30"},
            {"start_time": "2015-03-30 03:00:00"},
            {"start_time": datetime.datetime.now()},
            {"stop_time": ttime.time()},
            {"start_time": ttime.time() - 1, "stop_time": ttime.time()},
            {"beamline_id": "csx"},
            {"project": "world-domination"},
            {"owner": "drdrake"},
            {"scan_id": 1},
            {"uid": run_start_uid},
        ],
        mdsc.find_run_stops: [
            {"start_time": ttime.time()},
            {"stop_time": ttime.time()},
            {"start_time": ttime.time() - 1, "stop_time": ttime.time()},
            {"reason": "whimsy"},
            {"exit_status": "success"},
            {"run_start": rs},
            {"run_start_uid": rs.uid},
            {"uid": "foo"},
        ],
        mdsc.find_descriptors: [
            {"run_start": rs},
            {"run_start": rs.uid},
            {"start_time": ttime.time()},
            {"stop_time": ttime.time()},
            {"start_time": ttime.time() - 1, "stop_time": ttime.time()},
            {"uid": "foo"},
        ],
    }
    for func, list_o_dicts in test_dict.items():
        for dct in list_o_dicts:
            yield _find_helper, func, dct
Ejemplo n.º 6
0
def test_find_funcs_for_smoke():
    rs, = mdsc.find_run_starts(uid=run_start_uid)
    test_dict = {
        mdsc.find_run_starts: [{
            'limit': 5
        }, {
            'start_time': ttime.time()
        }, {
            'start_time': '2015'
        }, {
            'start_time': '2015-03-30'
        }, {
            'start_time': '2015-03-30 03:00:00'
        }, {
            'start_time': datetime.datetime.now()
        }, {
            'stop_time': ttime.time()
        }, {
            'start_time': ttime.time() - 1,
            'stop_time': ttime.time()
        }, {
            'beamline_id': 'csx'
        }, {
            'project': 'world-domination'
        }, {
            'owner': 'drdrake'
        }, {
            'scan_id': 1
        }, {
            'uid': run_start_uid
        }],
        mdsc.find_run_stops: [{
            'start_time': ttime.time()
        }, {
            'stop_time': ttime.time()
        }, {
            'start_time': ttime.time() - 1,
            'stop_time': ttime.time()
        }, {
            'reason': 'whimsy'
        }, {
            'exit_status': 'success'
        }, {
            'run_start': rs
        }, {
            'run_start_uid': rs.uid
        }, {
            'uid': 'foo'
        }],
        mdsc.find_descriptors: [{
            'run_start': rs
        }, {
            'run_start': rs.uid
        }, {
            'start_time': ttime.time()
        }, {
            'stop_time': ttime.time()
        }, {
            'start_time': ttime.time() - 1,
            'stop_time': ttime.time()
        }, {
            'uid': 'foo'
        }],
    }
    for func, list_o_dicts in test_dict.items():
        for dct in list_o_dicts:
            yield _find_helper, func, dct