def test_get_behavior_stimulus_file(behavior_experiment_id, compare_val):
    api = BehaviorLimsApi(behavior_experiment_id)

    if compare_val is None:
        expected_fail = False
        try:
            api.get_behavior_stimulus_file()
        except OneResultExpectedError:
            expected_fail = True
        assert expected_fail is True
    else:
        assert api.get_behavior_stimulus_file() == compare_val
def test_get_ori_info_from_trial(
    behavior_experiment_id,
    ti,
    expected,
    exception,
):
    """was feeling worried that the values would be wrong,
    this helps reaffirm that maybe they are not...

    Notes
    -----
    - i may be rewriting code here but its more a sanity check really...
    """
    stim_output = pd.read_pickle(
        BehaviorLimsApi(behavior_experiment_id).get_behavior_stimulus_file())
    trial_log = stim_output['items']['behavior']['trial_log']

    if exception:
        with pytest.raises(exception):
            trials_processing.get_ori_info_from_trial(
                trial_log,
                ti,
            )
    else:
        assert trials_processing.get_ori_info_from_trial(
            trial_log,
            ti,
        ) == expected
def test_get_extended_trials(behavior_experiment_id):
    api = BehaviorLimsApi(behavior_experiment_id)
    df = api.get_extended_trials()
    ets = ExtendedTrialSchema(partial=False, many=True)
    data_list_cs = df.to_dict('records')
    data_list_cs_sc = ets.dump(data_list_cs)
    ets.load(data_list_cs_sc)

    df_fail = df.drop(['behavior_session_uuid'], axis=1)
    ets = ExtendedTrialSchema(partial=False, many=True)
    data_list_cs = df_fail.to_dict('records')
    data_list_cs_sc = ets.dump(data_list_cs)
    try:
        ets.load(data_list_cs_sc)
        raise RuntimeError(
            'This should have failed with marshmallow.schema.ValidationError')
    except ValidationError:
        pass
def test_behavior_session_id_to_foraging_id(behavior_session_uuid):
    foraging_id = BehaviorLimsApi.behavior_session_id_to_foraging_id(
        behavior_session_uuid)
    assert foraging_id == '394a910e-94c7-4472-9838-5345aff59ed8'
def test_foraging_id_to_behavior_session_id(behavior_session_uuid):
    behavior_session_id = BehaviorLimsApi.foraging_id_to_behavior_session_id(
        behavior_session_uuid)
    assert behavior_session_id == 823847007