Skip to content

Commit

Permalink
add tests for volume configurations
Browse files Browse the repository at this point in the history
Remove extra parameter in parametrize

Fix use of parameter in test

Fix parameter name
  • Loading branch information
pyrr committed Nov 5, 2024
1 parent dbcc996 commit 6740a53
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion providers/tests/amazon/aws/operators/test_ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,48 +192,54 @@ def test_template_fields_overrides(self):
)

@pytest.mark.parametrize(
"launch_type, capacity_provider_strategy,platform_version,tags,expected_args",
"launch_type, capacity_provider_strategy,platform_version,tags,volume_configurations,expected_args",
[
[
"EC2",
None,
None,
None,
None,
{"launchType": "EC2"},
],
[
"EXTERNAL",
None,
None,
None,
None,
{"launchType": "EXTERNAL"},
],
[
"FARGATE",
None,
"LATEST",
None,
None,
{"launchType": "FARGATE", "platformVersion": "LATEST"},
],
[
"EC2",
None,
None,
{"testTagKey": "testTagValue"},
None,
{"launchType": "EC2", "tags": [{"key": "testTagKey", "value": "testTagValue"}]},
],
[
"",
None,
None,
{"testTagKey": "testTagValue"},
None,
{"tags": [{"key": "testTagKey", "value": "testTagValue"}]},
],
[
None,
{"capacityProvider": "FARGATE_SPOT"},
"LATEST",
None,
None,
{
"capacityProviderStrategy": {"capacityProvider": "FARGATE_SPOT"},
"platformVersion": "LATEST",
Expand All @@ -244,6 +250,7 @@ def test_template_fields_overrides(self):
{"capacityProvider": "FARGATE_SPOT", "weight": 123, "base": 123},
"LATEST",
None,
None,
{
"capacityProviderStrategy": {
"capacityProvider": "FARGATE_SPOT",
Expand All @@ -258,11 +265,63 @@ def test_template_fields_overrides(self):
{"capacityProvider": "FARGATE_SPOT"},
"LATEST",
None,
None,
{
"capacityProviderStrategy": {"capacityProvider": "FARGATE_SPOT"},
"platformVersion": "LATEST",
},
],
[
"FARGATE",
None,
None,
None,
[{
"name": "ebs-volume",
"managedEBSVolume": {
"volumeType": "gp3",
"sizeInGiB": 10,
},
"roleArn": "arn:aws:iam:1111222333:role/ecsInfrastructureRole",
}],
{
'volumeConfigurations':
[{
"name": "ebs-volume",
"managedEBSVolume": {
"volumeType": "gp3",
"sizeInGiB": 10,
},
"roleArn": "arn:aws:iam:1111222333:role/ecsInfrastructureRole",
}],
}
],
[
None,
{"capacityProvider": "FARGATE_SPOT"},
None,
None,
[{
"name": "ebs-volume",
"managedEBSVolume": {
"volumeType": "gp3",
"sizeInGiB": 10,
},
"roleArn": "arn:aws:iam:1111222333:role/ecsInfrastructureRole",
}],
{
"capacityProviderStrategy": {"capacityProvider": "FARGATE_SPOT"},
'volumeConfigurations':
[{
"name": "ebs-volume",
"managedEBSVolume": {
"volumeType": "gp3",
"sizeInGiB": 10,
},
"roleArn": "arn:aws:iam:1111222333:role/ecsInfrastructureRole",
}],
}
],
],
)
@mock.patch.object(EcsRunTaskOperator, "xcom_push")
Expand All @@ -279,13 +338,15 @@ def test_execute_without_failures(
capacity_provider_strategy,
platform_version,
tags,
volume_configurations,
expected_args,
):
self.set_up_operator(
launch_type=launch_type,
capacity_provider_strategy=capacity_provider_strategy,
platform_version=platform_version,
tags=tags,
volume_configurations=volume_configurations,
)
client_mock.run_task.return_value = RESPONSE_WITHOUT_FAILURES

Expand Down

0 comments on commit 6740a53

Please sign in to comment.