File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import numpy as np
44import pytest
5+ import xarray as xr
56from click .testing import CliRunner
67
78from virtualship .cli .commands import fetch , init
1011
1112@pytest .fixture
1213def copernicus_no_download (monkeypatch ):
13- """Mock the download and open_dataset functions."""
14+ """Mock the copernicusmarine `subset` and ` open_dataset` functions, approximating the reanalysis products ."""
1415
1516 # mock for copernicusmarine.subset
1617 def fake_download (output_filename , output_directory , ** _ ):
1718 Path (output_directory ).joinpath (output_filename ).touch ()
1819
19- # mock for copernicusmarine.open_dataset
20- class DummyTime :
21- def __getitem__ (self , idx ):
22- return self
23-
24- @property
25- def values (self ):
26- return np .datetime64 ("2023-02-01" )
27-
28- class DummyDS (dict ):
29- def __getitem__ (self , key ):
30- if key == "time" :
31- return DummyTime ()
32- raise KeyError (key )
33-
3420 def fake_open_dataset (* args , ** kwargs ):
35- return DummyDS ()
21+ return xr .Dataset (
22+ coords = {
23+ "time" : (
24+ "time" ,
25+ [
26+ np .datetime64 ("1993-01-01" ),
27+ np .datetime64 ("2022-01-01" ),
28+ ], # mock up rough renanalysis period
29+ )
30+ }
31+ )
3632
3733 monkeypatch .setattr ("virtualship.cli._fetch.copernicusmarine.subset" , fake_download )
3834 monkeypatch .setattr (
You can’t perform that action at this time.
0 commit comments