Skip to content

Commit e54d6d1

Browse files
committed
fixed CI
1 parent 3bd8667 commit e54d6d1

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

test/accessors/test_cds.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23+
from requests.exceptions import HTTPError
24+
from requests.models import Response
2325
import unittest
2426
from unittest.mock import MagicMock
2527

@@ -58,11 +60,12 @@ def test_open_data_spatial_res(self):
5860
self.assertEqual([10], [ds.sizes["time"]])
5961

6062
def test_open_data_splits(self):
63+
6164
# Fail first call, succeed sequentially on split halves
6265
def side_effect(*args, **kwargs):
6366
time_range = kwargs.get("time_range")
6467
if time_range == ("2025-01-01", "2025-01-10"):
65-
raise Exception("Too large request")
68+
raise make_403_error("Cost limits exceeded")
6669
if time_range == ("2025-01-01", "2025-01-05"):
6770
return self.ds_3d.isel(time=slice(0, 5))
6871
if time_range == ("2025-01-06", "2025-01-10"):
@@ -76,10 +79,20 @@ def side_effect(*args, **kwargs):
7679
xr.testing.assert_equal(self.ds_3d, ds)
7780

7881
def test_open_with_split_base_case_error(self):
79-
self.accessor.store.open_data.side_effect = Exception("fail always")
82+
# Always raise 403 error
83+
self.accessor.store.open_data.side_effect = make_403_error()
8084

8185
with self.assertRaises(DataStoreError) as cm:
8286
_ = self.accessor.open_data(
83-
"era5-land", time_range=("2025-01-01", "2025-01-10")
87+
"era5-land",
88+
time_range=("2025-01-01", "2025-01-10"),
8489
)
90+
8591
self.assertIn("Cannot further split time range", str(cm.exception))
92+
93+
94+
def make_403_error(message="Cost limits exceeded"):
95+
response = Response()
96+
response.status_code = 403
97+
response._content = message.encode() # optional
98+
return HTTPError(message, response=response)

xcube_multistore/accessors/cds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def _open_with_split(
126126

127127
return xr.concat((left, right), dim="time")
128128

129-
# Not the size-limit error but a HTTPError → propagate it
129+
# Not a size-limit error but a HTTPError → propagate it
130130
raise
131131

132132

0 commit comments

Comments
 (0)