@@ -36,8 +36,10 @@ def mock_gcp_environment():
36
36
)
37
37
from cloudproxy .providers .settings import config
38
38
39
+ @patch ('cloudproxy.providers.gcp.functions.get_client' )
39
40
@patch ('uuid.uuid4' )
40
- def test_create_proxy (mock_uuid , mock_gcp_environment ):
41
+ def test_create_proxy (mock_uuid , mock_get_client , mock_gcp_environment ):
42
+ mock_get_client .return_value = (None , mock_gcp_environment )
41
43
"""Test create_proxy function"""
42
44
# Setup
43
45
mock_uuid .return_value = "test-uuid"
@@ -78,8 +80,9 @@ def test_create_proxy(mock_uuid, mock_gcp_environment):
78
80
assert body ["networkInterfaces" ][0 ]["accessConfigs" ][0 ]["type" ] == "ONE_TO_ONE_NAT"
79
81
assert "startup-script" in body ["metadata" ]["items" ][0 ]["key" ]
80
82
81
- def test_delete_proxy_success (mock_gcp_environment ):
82
- """Test delete_proxy function successful case"""
83
+ @patch ('cloudproxy.providers.gcp.functions.get_client' )
84
+ def test_delete_proxy_success (mock_get_client , mock_gcp_environment ):
85
+ mock_get_client .return_value = (None , mock_gcp_environment )
83
86
# Setup
84
87
mock_compute = mock_gcp_environment
85
88
name = "cloudproxy-123"
@@ -101,8 +104,9 @@ def test_delete_proxy_success(mock_gcp_environment):
101
104
)
102
105
assert result == {"status" : "RUNNING" }
103
106
104
- def test_delete_proxy_http_error (mock_gcp_environment ):
105
- """Test delete_proxy function when HTTP error occurs"""
107
+ @patch ('cloudproxy.providers.gcp.functions.get_client' )
108
+ def test_delete_proxy_http_error (mock_get_client , mock_gcp_environment ):
109
+ mock_get_client .return_value = (None , mock_gcp_environment )
106
110
# Setup
107
111
mock_compute = mock_gcp_environment
108
112
name = "cloudproxy-123"
@@ -121,8 +125,9 @@ def test_delete_proxy_http_error(mock_gcp_environment):
121
125
# Verify
122
126
assert result is None
123
127
124
- def test_stop_proxy_success (mock_gcp_environment ):
125
- """Test stop_proxy function successful case"""
128
+ @patch ('cloudproxy.providers.gcp.functions.get_client' )
129
+ def test_stop_proxy_success (mock_get_client , mock_gcp_environment ):
130
+ mock_get_client .return_value = (None , mock_gcp_environment )
126
131
# Setup
127
132
mock_compute = mock_gcp_environment
128
133
name = "cloudproxy-123"
@@ -144,8 +149,9 @@ def test_stop_proxy_success(mock_gcp_environment):
144
149
)
145
150
assert result == {"status" : "STOPPING" }
146
151
147
- def test_stop_proxy_http_error (mock_gcp_environment ):
148
- """Test stop_proxy function when HTTP error occurs"""
152
+ @patch ('cloudproxy.providers.gcp.functions.get_client' )
153
+ def test_stop_proxy_http_error (mock_get_client , mock_gcp_environment ):
154
+ mock_get_client .return_value = (None , mock_gcp_environment )
149
155
# Setup
150
156
mock_compute = mock_gcp_environment
151
157
name = "cloudproxy-123"
@@ -164,8 +170,9 @@ def test_stop_proxy_http_error(mock_gcp_environment):
164
170
# Verify
165
171
assert result is None
166
172
167
- def test_start_proxy_success (mock_gcp_environment ):
168
- """Test start_proxy function successful case"""
173
+ @patch ('cloudproxy.providers.gcp.functions.get_client' )
174
+ def test_start_proxy_success (mock_get_client , mock_gcp_environment ):
175
+ mock_get_client .return_value = (None , mock_gcp_environment )
169
176
# Setup
170
177
mock_compute = mock_gcp_environment
171
178
name = "cloudproxy-123"
@@ -187,8 +194,9 @@ def test_start_proxy_success(mock_gcp_environment):
187
194
)
188
195
assert result == {"status" : "RUNNING" }
189
196
190
- def test_start_proxy_http_error (mock_gcp_environment ):
191
- """Test start_proxy function when HTTP error occurs"""
197
+ @patch ('cloudproxy.providers.gcp.functions.get_client' )
198
+ def test_start_proxy_http_error (mock_get_client , mock_gcp_environment ):
199
+ mock_get_client .return_value = (None , mock_gcp_environment )
192
200
# Setup
193
201
mock_compute = mock_gcp_environment
194
202
name = "cloudproxy-123"
@@ -207,8 +215,9 @@ def test_start_proxy_http_error(mock_gcp_environment):
207
215
# Verify
208
216
assert result is None
209
217
210
- def test_list_instances_with_instances (mock_gcp_environment ):
211
- """Test list_instances function when instances exist"""
218
+ @patch ('cloudproxy.providers.gcp.functions.get_client' )
219
+ def test_list_instances_with_instances (mock_get_client , mock_gcp_environment ):
220
+ mock_get_client .return_value = (None , mock_gcp_environment )
212
221
# Setup
213
222
mock_compute = mock_gcp_environment
214
223
@@ -238,8 +247,9 @@ def test_list_instances_with_instances(mock_gcp_environment):
238
247
assert len (result ) == 1
239
248
assert result [0 ]["name" ] == "cloudproxy-123"
240
249
241
- def test_list_instances_no_instances (mock_gcp_environment ):
242
- """Test list_instances function when no instances exist"""
250
+ @patch ('cloudproxy.providers.gcp.functions.get_client' )
251
+ def test_list_instances_no_instances (mock_get_client , mock_gcp_environment ):
252
+ mock_get_client .return_value = (None , mock_gcp_environment )
243
253
# Setup
244
254
mock_compute = mock_gcp_environment
245
255
0 commit comments