3
3
# interaction and replace with local file operations.
4
4
5
5
import botocore
6
- import contextlib
7
6
import os
8
- import h5netcdf
9
7
import numpy as np
10
8
import pyfive
11
9
import pytest
@@ -85,8 +83,9 @@ def reduce_chunk(
85
83
86
84
assert result == 999.0
87
85
88
- # S3 loading is not done from Active anymore
89
- mock_load .assert_not_called ()
86
+ # S3 loading is done from Active
87
+ # but we should delegate that outside at some point
88
+ # mock_load.assert_not_called()
90
89
91
90
# NOTE: This gets called multiple times with various arguments. Match on
92
91
# the common ones.
@@ -113,9 +112,8 @@ def reduce_chunk(
113
112
def test_reductionist_version_0 (mock_load , tmp_path ):
114
113
"""Test stack when call to Active contains storage_type == s3 using version 0."""
115
114
116
- @contextlib .contextmanager
117
115
def load_from_s3 (uri , storage_options = None ):
118
- yield h5netcdf .File (test_file , 'r' , invalid_netcdf = True )
116
+ return pyfive .File (test_file )
119
117
120
118
mock_load .side_effect = load_from_s3
121
119
@@ -148,9 +146,8 @@ def test_s3_load_failure(mock_load):
148
146
def test_reductionist_connection (mock_reduce , mock_load , tmp_path ):
149
147
"""Test stack when call to Active contains storage_type == s3."""
150
148
151
- @contextlib .contextmanager
152
149
def load_from_s3 (uri , storage_options = None ):
153
- yield h5netcdf .File (test_file , 'r' , invalid_netcdf = True )
150
+ return pyfive .File (test_file )
154
151
155
152
mock_load .side_effect = load_from_s3
156
153
mock_reduce .side_effect = requests .exceptions .ConnectTimeout ()
@@ -172,9 +169,8 @@ def load_from_s3(uri, storage_options=None):
172
169
def test_reductionist_bad_request (mock_reduce , mock_load , tmp_path ):
173
170
"""Test stack when call to Active contains storage_type == s3."""
174
171
175
- @contextlib .contextmanager
176
172
def load_from_s3 (uri , storage_options = None ):
177
- yield h5netcdf .File (test_file , 'r' , invalid_netcdf = True )
173
+ return pyfive .File (test_file )
178
174
179
175
mock_load .side_effect = load_from_s3
180
176
mock_reduce .side_effect = activestorage .reductionist .ReductionistError (400 , "Bad request" )
0 commit comments