コード例 #1
0
ファイル: test_rules.py プロジェクト: scitran/core
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
ファイル: test_rules.py プロジェクト: scitran/core
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
ファイル: test_rules.py プロジェクト: scitran/core
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
ファイル: test_rules.py プロジェクト: rfdougherty/core
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
ファイル: test_rules.py プロジェクト: scitran/core
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
ファイル: test_rules.py プロジェクト: ehlertjd/core-1
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
ファイル: test_rules.py プロジェクト: rfdougherty/core
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
ファイル: test_rules.py プロジェクト: rfdougherty/core
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
ファイル: test_rules.py プロジェクト: scitran/core
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
ファイル: test_rules.py プロジェクト: scitran/core
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
ファイル: test_rules.py プロジェクト: ehlertjd/core-1
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
ファイル: test_rules.py プロジェクト: scitran/core
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
ファイル: test_rules.py プロジェクト: ehlertjd/core-1
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
ファイル: test_rules.py プロジェクト: ehlertjd/core-1
def test_eval_match_unknown_type():
    with pytest.raises(Exception):
        rules.eval_match('does-not-exist', None, None, None)
コード例 #21
0
ファイル: test_rules.py プロジェクト: scitran/core
def test_eval_match_unknown_type():
    with pytest.raises(Exception):
        rules.eval_match('does-not-exist', None, None, None)