def test_database_specify(name, db_dict): # First check that at least some sesame mirror is up for url in sesame_url.get(): if urllib.request.urlopen(url).getcode() == 200: break else: pytest.skip("All SESAME mirrors appear to be down, skipping " "test_name_resolve.py:test_database_specify()...") for db in db_dict.keys(): with sesame_database.set(db): icrs = SkyCoord.from_name(name) time.sleep(1)
def test_name_resolve_cache(tmpdir): from astropy.utils.data import get_cached_urls target_name = "castor" temp_cache_dir = str(tmpdir.mkdir('cache')) with paths.set_temp_cache(temp_cache_dir, delete=True): assert len(get_cached_urls()) == 0 icrs1 = get_icrs_coordinates(target_name, cache=True) urls = get_cached_urls() assert len(urls) == 1 expected_urls = sesame_url.get() assert any([urls[0].startswith(x) for x in expected_urls]), f'{urls[0]} not in {expected_urls}' # Try reloading coordinates, now should just reload cached data: with no_internet(): icrs2 = get_icrs_coordinates(target_name, cache=True) assert len(get_cached_urls()) == 1 assert u.allclose(icrs1.ra, icrs2.ra) assert u.allclose(icrs1.dec, icrs2.dec)