def test_erddap_ds_exists(): assert isinstance(erddap_ds_exists(ds='ArgoFloats'), bool) assert erddap_ds_exists(ds='DummyDS') == False # We disable this test because the server has not responded over a week (May 29th) # @unittest.skipUnless(CONNECTED, "open_etopo1 requires an internet connection") # def test_open_etopo1(): # ds = open_etopo1([-80, -79, 20, 21], res='l') # assert isinstance(ds, xr.DataArray) == True
) AVAILABLE_SOURCES = list_available_data_src() AVAILABLE_INDEX_SOURCES = list_available_index_src() CONNECTED = isconnected() has_fetcher, requires_fetcher = _connectskip( len(AVAILABLE_SOURCES) > 0, "requires at least one data fetcher") has_fetcher_index, requires_fetcher_index = _connectskip( len(AVAILABLE_INDEX_SOURCES) > 0, "requires at least one index fetcher") ########## # ERDDAP # ########## if CONNECTED: DSEXISTS = erddap_ds_exists(ds="ArgoFloats") DSEXISTS_bgc = erddap_ds_exists(ds="ArgoFloats-bio") DSEXISTS_ref = erddap_ds_exists(ds="ArgoFloats-ref") DSEXISTS_index = erddap_ds_exists(ds="ArgoFloats-index") else: DSEXISTS = False DSEXISTS_bgc = False DSEXISTS_ref = False DSEXISTS_index = False has_connection, requires_connection = _connectskip( CONNECTED, "requires an internet connection") has_erddap, requires_erddap = _connectskip("erddap" in AVAILABLE_SOURCES, "requires erddap data fetcher")
import pytest import unittest from argopy import DataFetcher as ArgoDataFetcher from argopy.errors import InvalidDatasetStructure, ErddapServerError from argopy.utilities import list_available_data_src, isconnected, erddap_ds_exists AVAILABLE_SOURCES = list_available_data_src() CONNECTED = isconnected() if CONNECTED: DSEXISTS = erddap_ds_exists(ds="ArgoFloats") else: DSEXISTS = False @unittest.skipUnless('erddap' in AVAILABLE_SOURCES, "requires erddap data fetcher") @unittest.skipUnless(CONNECTED, "erddap requires an internet connection") @unittest.skipUnless(DSEXISTS, "erddap requires a valid core Argo dataset from Ifremer server") def test_point2profile(): try: ds = ArgoDataFetcher(src='erddap')\ .region([-75, -55, 30., 40., 0, 100., '2011-01-01', '2011-01-15'])\ .to_xarray() assert 'N_PROF' in ds.argo.point2profile().dims except ErddapServerError: # Test is passed when something goes wrong because of the erddap server, not our fault ! pass @unittest.skipUnless('erddap' in AVAILABLE_SOURCES, "requires erddap data fetcher") @unittest.skipUnless(CONNECTED, "erddap requires an internet connection") @unittest.skipUnless(DSEXISTS, "erddap requires a valid core Argo dataset from Ifremer server")
import pytest import unittest from unittest import TestCase import argopy from argopy import IndexFetcher as ArgoIndexFetcher from argopy.errors import InvalidFetcherAccessPoint, InvalidFetcher, \ FileSystemHasNoCache, CacheFileNotFound, ErddapServerError, DataNotFound from argopy.utilities import list_available_index_src, isconnected, erddap_ds_exists AVAILABLE_INDEX_SOURCES = list_available_index_src() CONNECTED = isconnected() if CONNECTED: DSEXISTS = erddap_ds_exists(ds="ArgoFloats-index") else: DSEXISTS = False def test_invalid_accesspoint(): src = list( AVAILABLE_INDEX_SOURCES.keys())[0] # Use the first valid data source with pytest.raises(InvalidFetcherAccessPoint): ArgoIndexFetcher(src=src).invalid_accesspoint.to_xarray( ) # Can't get data if access point not defined first with pytest.raises(InvalidFetcherAccessPoint): ArgoIndexFetcher(src=src).to_xarray( ) # Can't get data if access point not defined first
def test_erddap_ds_exists(): assert isinstance(erddap_ds_exists(ds="ArgoFloats"), bool) assert erddap_ds_exists(ds="DummyDS") is False
def test_erddap_ds_exists(): assert isinstance(erddap_ds_exists(ds='ArgoFloats'), bool) assert erddap_ds_exists(ds='DummyDS') is False