示例#1
0
def test_eval_match_file_name_match_regex():
    part = rulePart(match_type='file.name', file_={'name': 'test.dicom.zip'}, regex=True)

    args = part.gen(match_param='.*DiC[o]{1}M\.zip$')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='.*DiC[o]{2}M\.zip$')
    result = rules.eval_match(*args)
    assert result == False
示例#2
0
def test_eval_match_file_classification_regex():
    part = rulePart(match_type='file.classification', file_={'classification': {'intent': ['diffusion']}}, regex=True)

    args = part.gen(match_param='test|diffusion')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='test|foo')
    result = rules.eval_match(*args)
    assert result == False
示例#3
0
def test_eval_match_file_measurements_regex():
    part = rulePart(match_type='file.measurements', file_={'measurements': ['diffusion']}, regex=True)

    args = part.gen(match_param='test|diffusion')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='test|foo')
    result = rules.eval_match(*args)
    assert result == False
示例#4
0
def test_eval_match_file_type_regex():
    part = rulePart(match_type='file.type', file_={'type': 'dicom'}, regex=True)

    args = part.gen(match_param='DiC[o]{1}M$')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='DiC[o]{2}M$')
    result = rules.eval_match(*args)
    assert result == False
示例#5
0
def test_eval_match_container_measurement():
    part = rulePart(match_type='container.measurement', container={'measurement': 'diffusion'})

    args = part.gen(match_param='diffusion')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='c')
    result = rules.eval_match(*args)
    assert result == False
示例#6
0
def test_eval_match_file_name_match_relative():
    part = rulePart(match_type='file.name', match_param='*.txt')

    args = part.gen(file_={'name': 'file.txt' })
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(file_={'name': 'file.log' })
    result = rules.eval_match(*args)
    assert result == False
示例#7
0
def test_eval_match_file_name_match_regex():
    part = rulePart(match_type='file.name', file_={'name': 'test.dicom.zip'}, regex=True)

    args = part.gen(match_param='.*DiC[o]{1}M\.zip$')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='.*DiC[o]{2}M\.zip$')
    result = rules.eval_match(*args)
    assert result == False
示例#8
0
def test_eval_match_file_type_regex():
    part = rulePart(match_type='file.type', file_={'type': 'dicom'}, regex=True)

    args = part.gen(match_param='DiC[o]{1}M$')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='DiC[o]{2}M$')
    result = rules.eval_match(*args)
    assert result == False
示例#9
0
def test_eval_match_file_name_match_exact():
    part = rulePart(match_type='file.name', match_param='file.txt')

    args = part.gen(file_={'name': 'file.txt'})
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(file_={'name': 'file2.txt'})
    result = rules.eval_match(*args)
    assert result == False
示例#10
0
def test_eval_match_container_measurement():
    part = rulePart(match_type='container.measurement',
                    container={'measurement': 'diffusion'})

    args = part.gen(match_param='diffusion')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='c')
    result = rules.eval_match(*args)
    assert result == False
示例#11
0
def test_eval_match_container_has_type():
    part = rulePart(match_type='container.has-type', container={'files': [
            {'measurements': ['a', 'diffusion', 'b']},
            {'measurements': ['c', 'other', 'b']},
        ]})

    args = part.gen(match_param='other')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='d')
    result = rules.eval_match(*args)
    assert result == False
示例#12
0
def test_eval_match_container_has_type():
    part = rulePart(match_type='container.has-type', container={'files': [
            {'type': 'diffusion'},
            {'type': 'other'},
        ]})

    args = part.gen(match_param='other')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='d')
    result = rules.eval_match(*args)
    assert result == False
示例#13
0
def test_eval_match_container_has_type_regex():
    part = rulePart(match_type='container.has-type', regex=True, container={'files': [
        {'type': 'diffusion'},
        {'type': 'other'},
    ]})

    args = part.gen(match_param='test|diffusion')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='test|foo')
    result = rules.eval_match(*args)
    assert result == False
示例#14
0
def test_eval_match_file_type():
    part = rulePart(match_type='file.type', match_param='dicom')

    args = part.gen(file_={'type': 'dicom' })
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(file_={'type': 'nifti' })
    result = rules.eval_match(*args)
    assert result == False

    # Check match returns false without raising when not given a file.type
    args = part.gen(file_={'a': 'b'}, container={'a': 'b'})
    result = rules.eval_match(*args)
    assert result == False
示例#15
0
def test_eval_match_file_classification():
    part = rulePart(match_type='file.classification', file_={'classification': {'intent': ['a', 'diffusion', 'b'] }})

    args = part.gen(match_param='diffusion')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='c')
    result = rules.eval_match(*args)
    assert result == False

    # Check match returns false without raising when not given a file.classification
    args = part.gen(match_param='', file_={'a': 'b'}, container={'a': 'b'})
    result = rules.eval_match(*args)
    assert result == False
示例#16
0
def test_eval_match_file_measurements():
    part = rulePart(match_type='file.measurements', file_={'measurements': ['a', 'diffusion', 'b'] })

    args = part.gen(match_param='diffusion')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='c')
    result = rules.eval_match(*args)
    assert result == False

    # Check match returns false without raising when not given a file.type
    args = part.gen(file_={'a': 'b'}, container={'a': 'b'})
    result = rules.eval_match(*args)
    assert result == False
示例#17
0
def test_eval_match_file_modality():
    part = rulePart(match_type='file.modality', match_param='MR')

    args = part.gen(file_={'modality': 'mr'})
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(file_={'modality': 'CT'})
    result = rules.eval_match(*args)
    assert result == False

    # Check match returns false without raising when not given a file.modality
    args = part.gen(file_={'a': 'b'}, container={'a': 'b'})
    result = rules.eval_match(*args)
    assert result == False
示例#18
0
def test_eval_match_file_measurements():
    part = rulePart(match_type='file.measurements', file_={'measurements': ['a', 'diffusion', 'b'] })

    args = part.gen(match_param='diffusion')
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(match_param='c')
    result = rules.eval_match(*args)
    assert result == False

    # Check match returns false without raising when not given a file.measurement
    args = part.gen(match_param='', file_={'a': 'b'}, container={'a': 'b'})
    result = rules.eval_match(*args)
    assert result == False
示例#19
0
def test_eval_match_file_type():
    part = rulePart(match_type='file.type', match_param='dicom')

    args = part.gen(file_={'type': 'dicom'})
    result = rules.eval_match(*args)
    assert result == True

    args = part.gen(file_={'type': 'nifti'})
    result = rules.eval_match(*args)
    assert result == False

    # Check match returns false without raising when not given a file.type
    args = part.gen(file_={'a': 'b'}, container={'a': 'b'})
    result = rules.eval_match(*args)
    assert result == False
示例#20
0
def test_eval_match_unknown_type():
    with pytest.raises(Exception):
        rules.eval_match('does-not-exist', None, None, None)
示例#21
0
def test_eval_match_unknown_type():
    with pytest.raises(Exception):
        rules.eval_match('does-not-exist', None, None, None)