Esempio n. 1
0
def test_container_errors_all_true():
    with mock.patch('run.validate', return_value=list()):
        errors = run.get_container_errors([{}], {}, {})

    assert len(errors) == 1
    assert errors[0].get('resolved') is True
    assert errors[0].get('error') is None
Esempio n. 2
0
def test_container_errors_all_error():
    with mock.patch('run.validate', return_value=['Oh no!']):
        errors = run.get_container_errors([{}], {}, {})

    assert len(errors) == 1
    assert errors[0].get('resolved') is False
    assert errors[0].get('error') is 'Oh no!'
Esempio n. 3
0
def test_container_errors_multiple_error():
    with mock.patch('run.validate', side_effect=[list(), ['Oh no!']]):
        errors = run.get_container_errors([{}, {}], {}, {})

    assert len(errors) == 2
    assert errors[0].get('resolved') is True
    assert errors[0].get('error') is None
    assert errors[1].get('resolved') is False
    assert errors[1].get('error') is 'Oh no!'
Esempio n. 4
0
def test_fix_all():
    error_list_path = DATA_ROOT / 'test_error_list.json'
    with open(error_list_path) as err_data:
        error_list = json.load(err_data)
    test_dict = {
        'info': {
            'header': {
                'dicom': {
                    'Modality': 'MR',
                    'ImageType': ['NORM'],
                    'StudyDate': 'defined'
                }
            }
        }
    }
    ret_error_dicts = run.get_container_errors(error_list, test_dict, dict())
    for item in ret_error_dicts:
        assert item.get('resolved')
Esempio n. 5
0
def test_fail_all_validate():
    error_list_path = DATA_ROOT / 'test_error_list.json'
    with open(error_list_path) as err_data:
        error_list = json.load(err_data)
    test_dict = {
        'info': {
            'header': {
                'dicom': {
                    'Modality': 'NM',
                    'ImageType': ['SCREEN SAVE'],
                    'Units': 'MLML'
                }
            }
        }
    }
    ret_error_dicts = run.get_container_errors(error_list, test_dict, dict())
    ret_error_msg_list = set([error.get('error') for error in ret_error_dicts])
    exp_msg_list = set([error.get('error_message') for error in error_list])
    assert ret_error_msg_list == exp_msg_list