Skip to content

Commit d4740e5

Browse files
mock create channel for control client creation
1 parent fd0db46 commit d4740e5

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

gcsfs/tests/conftest.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,16 @@ def docker_gcs():
126126
container = "gcsfs_test"
127127
cmd = (
128128
"docker run -d -p 4443:4443 --name gcsfs_test fsouza/fake-gcs-server:latest -scheme "
129-
"https -public-host 0.0.0.0:4443 -external-url https://localhost:4443 "
129+
"http -public-host 0.0.0.0:4443 -external-url http://localhost:4443 "
130130
"-backend memory"
131131
)
132132
stop_docker(container)
133133
subprocess.check_output(shlex.split(cmd))
134-
url = "https://localhost:4443"
134+
url = "http://0.0.0.0:4443"
135135
timeout = 10
136136
while True:
137137
try:
138-
r = requests.get(url + "/storage/v1/b", verify=False)
138+
r = requests.get(url + "/storage/v1/b")
139139
if r.ok:
140140
yield url
141141
break
@@ -147,6 +147,20 @@ def docker_gcs():
147147
stop_docker(container)
148148

149149

150+
@pytest.fixture(autouse=True)
151+
def mock_control_plane_channel():
152+
from unittest import mock
153+
154+
# Mock create_channel to prevent real gRPC channel creation to emulator
155+
target = (
156+
"google.cloud.storage_control_v2.services.storage_control.transports."
157+
"grpc_asyncio.StorageControlGrpcAsyncIOTransport.create_channel"
158+
)
159+
with mock.patch(target) as mock_create:
160+
mock_create.return_value = mock.Mock() # Return a dummy channel
161+
yield mock_create
162+
163+
150164
@pytest.fixture(scope="session")
151165
def gcs_factory(docker_gcs):
152166
params["endpoint_url"] = docker_gcs

0 commit comments

Comments
 (0)