def test_get_batch(): batch = neurovault._get_batch(neurovault._NEUROVAULT_COLLECTIONS_URL) assert('results' in batch) assert('count' in batch) assert_raises(neurovault.URLError, neurovault._get_batch, 'http://') with _TestTemporaryDirectory() as temp_dir: with open(os.path.join(temp_dir, 'test_nv.txt'), 'w'): pass assert_raises(ValueError, neurovault._get_batch, 'file://{0}'.format( os.path.join(temp_dir, 'test_nv.txt'))) no_results_url = ('https://eutils.ncbi.nlm.nih.gov/entrez/eutils/' 'esearch.fcgi?db=pmc&retmode=json&term=fmri') assert_raises(ValueError, neurovault._get_batch, no_results_url)
def test_get_batch(): batch = neurovault._get_batch(neurovault._NEUROVAULT_COLLECTIONS_URL) assert ('results' in batch) assert ('count' in batch) pytest.raises(requests.RequestException, neurovault._get_batch, 'http://') with tempfile.TemporaryDirectory() as temp_dir: with open(os.path.join(temp_dir, 'test_nv.txt'), 'w'): pass pytest.raises( ValueError, neurovault._get_batch, 'file://{0}'.format(os.path.join(temp_dir, 'test_nv.txt'))) no_results_url = ('https://eutils.ncbi.nlm.nih.gov/entrez/eutils/' 'esearch.fcgi?db=pmc&retmode=json&term=fmri') pytest.raises(ValueError, neurovault._get_batch, no_results_url)