def __testthis(self): for access_point in self.args: if access_point == "profile": for arg in self.args["profile"]: with argopy.set_options(local_ftp=self.local_ftp): fetcher = ArgoIndexFetcher(src=self.src).profile( *arg).fetcher df = fetcher.to_dataframe() assert isinstance(df, pd.core.frame.DataFrame) if access_point == "float": for arg in self.args["float"]: with argopy.set_options(local_ftp=self.local_ftp): fetcher = ArgoIndexFetcher( src=self.src).float(arg).fetcher df = fetcher.to_dataframe() assert isinstance(df, pd.core.frame.DataFrame) if access_point == "region": for arg in self.args["region"]: with argopy.set_options(local_ftp=self.local_ftp): fetcher = ArgoIndexFetcher( src=self.src).region(arg).fetcher df = fetcher.to_dataframe() assert isinstance(df, pd.core.frame.DataFrame)
def test_nocache(self): with tempfile.TemporaryDirectory() as testcachedir: with argopy.set_options(cachedir=testcachedir, local_ftp=self.local_ftp): loader = ArgoIndexFetcher( src=self.src, cache=False).profile(*self.requests['profile'][0]) loader.to_dataframe() with pytest.raises(FileSystemHasNoCache): loader.fetcher.cachepath
def test_caching(self): with tempfile.TemporaryDirectory() as testcachedir: with argopy.set_options(cachedir=testcachedir, local_ftp=self.local_ftp): loader = ArgoIndexFetcher(src=self.src, cache=True).float( self.requests['float'][0]) # 1st call to load and save to cache: loader.to_dataframe() # 2nd call to load from cached file: df = loader.to_dataframe() assert isinstance(df, pd.core.frame.DataFrame) assert isinstance(loader.fetcher.cachepath, str)
def test_clearcache(self): with tempfile.TemporaryDirectory() as testcachedir: with argopy.set_options(cachedir=testcachedir, local_ftp=self.local_ftp): loader = ArgoIndexFetcher( src=self.src, cache=True).profile(*self.requests['profile'][0]) loader.to_dataframe( ) # 1st call to load from source and save in memory loader.to_dataframe( ) # 2nd call to load from memory and save in cache loader.clear_cache() with pytest.raises(CacheFileNotFound): loader.fetcher.cachepath