Skip to content

Commit

Permalink
Merge pull request #2648 from ASFHyP3/jth-start-execution-tests
Browse files Browse the repository at this point in the history
Combine start execution lambda handler tests into one
  • Loading branch information
jtherrmann authored Mar 7, 2025
2 parents 8936274 + b979e33 commit c214e68
Showing 1 changed file with 6 additions and 61 deletions.
67 changes: 6 additions & 61 deletions tests/test_start_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,72 +181,17 @@ def test_submit_jobs():
]


def test_lambda_handler_500_jobs():
def test_lambda_handler():
with (
patch('dynamo.jobs.get_jobs_waiting_for_execution') as mock_get_jobs_waiting_for_execution,
patch('dynamo.util.convert_decimals_to_numbers') as mock_convert_decimals_to_numbers,
patch('start_execution.submit_jobs') as mock_submit_jobs,
patch.dict(os.environ, {'STEP_FUNCTION_ARN': 'test-step-function-arn'}, clear=True),
):
mock_jobs = list(range(500))
mock_get_jobs_waiting_for_execution.return_value = mock_jobs

mock_submit_jobs.return_value = None

start_execution.lambda_handler({}, None)

mock_get_jobs_waiting_for_execution.assert_called_once_with(limit=500)

assert mock_submit_jobs.mock_calls == [call(mock_jobs)]


def test_lambda_handler_400_jobs():
with (
patch('dynamo.jobs.get_jobs_waiting_for_execution') as mock_get_jobs_waiting_for_execution,
patch('start_execution.submit_jobs') as mock_submit_jobs,
patch.dict(os.environ, {'STEP_FUNCTION_ARN': 'test-step-function-arn'}, clear=True),
):
mock_jobs = list(range(400))
mock_get_jobs_waiting_for_execution.return_value = mock_jobs

mock_submit_jobs.return_value = None

start_execution.lambda_handler({}, None)

mock_get_jobs_waiting_for_execution.assert_called_once_with(limit=500)

assert mock_submit_jobs.mock_calls == [call(mock_jobs)]


def test_lambda_handler_50_jobs():
with (
patch('dynamo.jobs.get_jobs_waiting_for_execution') as mock_get_jobs_waiting_for_execution,
patch('start_execution.submit_jobs') as mock_submit_jobs,
patch.dict(os.environ, {'STEP_FUNCTION_ARN': 'test-step-function-arn'}, clear=True),
):
mock_jobs = list(range(50))
mock_get_jobs_waiting_for_execution.return_value = mock_jobs

mock_submit_jobs.return_value = None
mock_get_jobs_waiting_for_execution.return_value = 'mock_jobs'
mock_convert_decimals_to_numbers.return_value = 'converted_jobs'

start_execution.lambda_handler({}, None)

mock_get_jobs_waiting_for_execution.assert_called_once_with(limit=500)

assert mock_submit_jobs.mock_calls == [call(mock_jobs)]


def test_lambda_handler_no_jobs():
with (
patch('dynamo.jobs.get_jobs_waiting_for_execution') as mock_get_jobs_waiting_for_execution,
patch('start_execution.submit_jobs') as mock_submit_jobs,
patch.dict(os.environ, {'STEP_FUNCTION_ARN': 'test-step-function-arn'}, clear=True),
):
mock_get_jobs_waiting_for_execution.return_value = []

mock_submit_jobs.return_value = None

start_execution.lambda_handler({}, None)

mock_get_jobs_waiting_for_execution.assert_called_once_with(limit=500)

assert mock_submit_jobs.mock_calls == [call([])]
mock_convert_decimals_to_numbers.assert_called_once_with('mock_jobs')
mock_submit_jobs.assert_called_once_with('converted_jobs')

0 comments on commit c214e68

Please sign in to comment.