Skip to content

Commit ca30bb2

Browse files
committed
fix mocker tests
1 parent 3294052 commit ca30bb2

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

tests/unit/test_storage_types.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
# interaction and replace with local file operations.
44

55
import botocore
6-
import contextlib
76
import os
8-
import h5netcdf
97
import numpy as np
108
import pyfive
119
import pytest
@@ -85,8 +83,9 @@ def reduce_chunk(
8583

8684
assert result == 999.0
8785

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()
9089

9190
# NOTE: This gets called multiple times with various arguments. Match on
9291
# the common ones.
@@ -113,9 +112,8 @@ def reduce_chunk(
113112
def test_reductionist_version_0(mock_load, tmp_path):
114113
"""Test stack when call to Active contains storage_type == s3 using version 0."""
115114

116-
@contextlib.contextmanager
117115
def load_from_s3(uri, storage_options=None):
118-
yield h5netcdf.File(test_file, 'r', invalid_netcdf=True)
116+
return pyfive.File(test_file)
119117

120118
mock_load.side_effect = load_from_s3
121119

@@ -148,9 +146,8 @@ def test_s3_load_failure(mock_load):
148146
def test_reductionist_connection(mock_reduce, mock_load, tmp_path):
149147
"""Test stack when call to Active contains storage_type == s3."""
150148

151-
@contextlib.contextmanager
152149
def load_from_s3(uri, storage_options=None):
153-
yield h5netcdf.File(test_file, 'r', invalid_netcdf=True)
150+
return pyfive.File(test_file)
154151

155152
mock_load.side_effect = load_from_s3
156153
mock_reduce.side_effect = requests.exceptions.ConnectTimeout()
@@ -172,9 +169,8 @@ def load_from_s3(uri, storage_options=None):
172169
def test_reductionist_bad_request(mock_reduce, mock_load, tmp_path):
173170
"""Test stack when call to Active contains storage_type == s3."""
174171

175-
@contextlib.contextmanager
176172
def load_from_s3(uri, storage_options=None):
177-
yield h5netcdf.File(test_file, 'r', invalid_netcdf=True)
173+
return pyfive.File(test_file)
178174

179175
mock_load.side_effect = load_from_s3
180176
mock_reduce.side_effect = activestorage.reductionist.ReductionistError(400, "Bad request")

0 commit comments

Comments
 (0)