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'
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)
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.'
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)