Пример #1
0
def test_validate_and_write_extended_validation(req):
    """Test extended validation before writing."""
    handle = StringIO()
    req.get('http://fake/', text=u'>foo\nMAGIC')
    r = requests.get('http://fake/')
    config = core.Config(extended_validation='loads', molecule='protein')
    core._validate_and_write(r, handle, 'FAKE', config)

    assert handle.getvalue() == u'>foo\nMAGIC'
Пример #2
0
def test_validate_and_write_error_pattern_raises(req):
    """Test scanning the download file for error patterns."""
    handle = StringIO()
    req.get('http://fake/', text=u'ID list is empty')
    r = requests.get('http://fake/')
    config = core.Config()

    with pytest.raises(core.BadPatternError):
        core._validate_and_write(r, handle, 'FAKE', config)
Пример #3
0
def test_validate_and_write_emit(req):
    """Test writing prints dots in verbose mode."""
    handle = StringIO()
    req.get('http://fake/', text=u'This is a sequence file, honest.')
    r = requests.get('http://fake/')
    output = StringIO()
    config = core.Config()
    config.emit = output.write
    core._validate_and_write(r, handle, 'FAKE', config)

    assert output.getvalue() == u'.\n'
    assert handle.getvalue() == u'This is a sequence file, honest.'
Пример #4
0
def test_validate_and_write_error_pattern_raises(req):
    """Test scanning the download file for error patterns."""
    handle = StringIO()
    req.get('http://fake/', text=u'ID list is empty')
    r = requests.get('http://fake/')
    config = core.Config()

    with pytest.raises(BadPatternError):
        core._validate_and_write(r, handle, 'FAKE', config)

    req.get('http://fake/', text=u'Error: CEFetchPApplication::proxy_stream(): Failed to retrieve sequence: NC_405534')
    r = requests.get('http://fake/')
    with pytest.raises(BadPatternError):
        core._validate_and_write(r, handle, 'FAKE', config)