Skip to content

Commit e099de9

Browse files
committed
Add mock_env fixture to all test functions that need AWS region
1 parent aeb0219 commit e099de9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/createIndexFunction/tests/test_handler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def mock_opensearch_client():
3333

3434

3535
@patch("app.handler.boto3.Session")
36-
def test_get_opensearch_client(mock_session):
36+
def test_get_opensearch_client(mock_session, mock_env):
3737
"""Test OpenSearch client creation"""
3838
mock_credentials = Mock()
3939
mock_session.return_value.get_credentials.return_value = mock_credentials
@@ -125,7 +125,7 @@ def test_extract_parameters_direct():
125125

126126
@patch("app.handler.get_opensearch_client")
127127
@patch("app.handler.create_and_wait_for_index")
128-
def test_handler_create(mock_create_wait, mock_get_client, lambda_context):
128+
def test_handler_create(mock_create_wait, mock_get_client, mock_env, lambda_context):
129129
"""Test handler for Create request"""
130130
mock_get_client.return_value = Mock()
131131

@@ -145,7 +145,7 @@ def test_handler_create(mock_create_wait, mock_get_client, lambda_context):
145145

146146

147147
@patch("app.handler.get_opensearch_client")
148-
def test_handler_delete(mock_get_client, mock_opensearch_client, lambda_context):
148+
def test_handler_delete(mock_get_client, mock_opensearch_client, mock_env, lambda_context):
149149
"""Test handler for Delete request"""
150150
mock_get_client.return_value = mock_opensearch_client
151151
mock_opensearch_client.indices.exists.return_value = True
@@ -167,7 +167,7 @@ def test_handler_delete(mock_get_client, mock_opensearch_client, lambda_context)
167167

168168

169169
@patch("app.handler.get_opensearch_client")
170-
def test_handler_missing_parameters(mock_get_client, lambda_context):
170+
def test_handler_missing_parameters(mock_get_client, mock_env, lambda_context):
171171
"""Test handler with missing parameters"""
172172
from app.handler import handler
173173

@@ -178,7 +178,7 @@ def test_handler_missing_parameters(mock_get_client, lambda_context):
178178

179179

180180
@patch("app.handler.get_opensearch_client")
181-
def test_handler_with_payload(mock_get_client, mock_opensearch_client, lambda_context):
181+
def test_handler_with_payload(mock_get_client, mock_opensearch_client, mock_env, lambda_context):
182182
"""Test handler with JSON payload"""
183183
mock_get_client.return_value = mock_opensearch_client
184184
mock_opensearch_client.indices.exists.return_value = True

0 commit comments

Comments
 (0)