Skip to content

Commit

Permalink
test: Add missing integration pattern test for ECS Task
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaei committed Jul 27, 2022
1 parent a6748d2 commit f7ca980
Showing 1 changed file with 49 additions and 13 deletions.
62 changes: 49 additions & 13 deletions tests/unit/test_compute_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,35 +101,71 @@ def test_batch_submit_job_step_creation():


@patch.object(boto3.session.Session, 'region_name', 'us-east-1')
def test_ecs_run_task_step_creation():
step = EcsRunTaskStep('Ecs Job', wait_for_completion=False)
@pytest.mark.parametrize(
("task_kwargs",),
[
({},),
({
"integration_pattern": IntegrationPattern.WaitForCompletion,
"wait_for_completion": False,
},),
]
)
def test_ecs_run_task_with_wait_for_completion(task_kwargs):
step = EcsRunTaskStep('ECS Job', **task_kwargs)

assert step.to_dict() == {
'Type': 'Task',
'Resource': 'arn:aws:states:::ecs:runTask',
'Resource': 'arn:aws:states:::ecs:runTask.sync',
'End': True
}

step = EcsRunTaskStep('Ecs Job',
integration_pattern=IntegrationPattern.WaitForTaskToken,
wait_for_completion=False)

@patch.object(boto3.session.Session, 'region_name', 'us-east-1')
@pytest.mark.parametrize(
("task_kwargs",),
[
({
"integration_pattern": IntegrationPattern.WaitForTaskToken,
"wait_for_completion": False,
},),
]
)
def test_ecs_run_task_with_wait_for_task_token(task_kwargs):
step = EcsRunTaskStep('ECS Job', **task_kwargs)

assert step.to_dict() == {
'Type': 'Task',
'Resource': 'arn:aws:states:::ecs:runTask.waitForTaskToken',
'End': True
}

step = EcsRunTaskStep('Ecs Job', parameters={
'TaskDefinition': 'Task'
})

@patch.object(boto3.session.Session, 'region_name', 'us-east-1')
@pytest.mark.parametrize(
("task_kwargs",),
[
({
"wait_for_completion": False,
},),
({
"integration_pattern": IntegrationPattern.CallAndContinue,
"wait_for_completion": False,
},)
]
)
def test_ecs_run_task_with_call_and_continue(task_kwargs):
step = EcsRunTaskStep('ECS Job', **task_kwargs)

assert step.to_dict() == {
'Type': 'Task',
'Resource': 'arn:aws:states:::ecs:runTask.sync',
'Parameters': {
'TaskDefinition': 'Task'
},
'Resource': 'arn:aws:states:::ecs:runTask',
'End': True
}


@patch.object(boto3.session.Session, 'region_name', 'us-east-1')
def test_ecs_run_task_with_conflicting_arguments():
with pytest.raises(ValueError):
step = EcsRunTaskStep('Ecs Job',
wait_for_completion=True,
Expand Down

0 comments on commit f7ca980

Please sign in to comment.