Skip to content

Commit

Permalink
Remove extra patches
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-griffin committed Dec 13, 2024
1 parent 23ed827 commit d796718
Showing 1 changed file with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1087,28 +1087,22 @@ def test_run_test_secret_with_test_domains(self, rotator):
"test-token": ["AWSPENDING"]
}
}

with patch('boto3.client') as mock_boto3_client, \
patch('rotate_secret_lambda.boto3.client') as mock_lambda_boto, \
patch('secret_rotator.boto3.client') as mock_secret_rotator_boto, \
patch.object(rotator, 'get_deployed_distributions') as mock_get_deployed_distributions, \
patch('rotate_secret_lambda.SecretRotator') as MockSecretRotator:

# Create a specific mock client to use
specific_mock_client = MagicMock()
mock_lambda_boto.return_value = specific_mock_client

mock_service_client = mock_boto3_client.return_value
mock_rotator_instance = MockSecretRotator.return_value

# mocks get_deployed_distributions and calls made in get_secrets() method
mock_get_deployed_distributions.return_value = mock_distributions
mock_service_client.describe_secret.return_value = mock_metadata
mock_service_client.get_secret_value.side_effect = [

mock_boto_client = MagicMock()
mock_boto_client.describe_secret.return_value = mock_metadata
mock_boto_client.get_secret_value.side_effect = [
mock_pending_secret,
mock_current_secret
]

rotator.get_deployed_distributions = MagicMock()
rotator.get_deployed_distributions.return_value = mock_distributions

with patch('boto3.client') as mock_boto_client, \
patch('rotate_secret_lambda.SecretRotator') as mock_rotator:

mock_rotator_instance = mock_rotator.return_value

from rotate_secret_lambda import lambda_handler
lambda_handler(event, None)

Expand All @@ -1118,7 +1112,6 @@ def test_run_test_secret_with_test_domains(self, rotator):

call_args = actual_calls[0][0]
for i, arg in enumerate(call_args):
# Assert with more detailed checking on provided arguments
assert call_args[1] == "test-arn"
assert call_args[2] == "test-token"
assert call_args[3] == ['domain1.example.com', 'domain2.example.com']
Expand Down

0 comments on commit d796718

Please sign in to comment.