コード例 #1
0
def test_get_task_definition_arn_provided_task_definition_arn():
    run_config = ECSRun(task_definition_arn="my-taskdef-arn")
    flow_run = GraphQLResult({"flow": GraphQLResult({"id": "flow-id", "version": 1})})
    agent = ECSAgent()

    res = agent.get_task_definition_arn(flow_run, run_config)
    assert res == "my-taskdef-arn"
コード例 #2
0
def test_get_task_definition_arn(aws, kind):
    if kind == "exists":
        aws.resourcegroupstaggingapi.get_resources.return_value = {
            "ResourceTagMappingList": [{"ResourceARN": "my-taskdef-arn"}]
        }
        expected = "my-taskdef-arn"
    elif kind == "missing":
        aws.resourcegroupstaggingapi.get_resources.return_value = {
            "ResourceTagMappingList": []
        }
        expected = None
    else:
        from botocore.exceptions import ClientError

        aws.resourcegroupstaggingapi.get_resources.side_effect = ClientError(
            {}, "GetResources"
        )
        expected = None

    run_config = ECSRun()
    flow_run = GraphQLResult({"flow": GraphQLResult({"id": "flow-id", "version": 1})})
    agent = ECSAgent()

    res = agent.get_task_definition_arn(flow_run, run_config)
    assert res == expected
    kwargs = aws.resourcegroupstaggingapi.get_resources.call_args[1]
    assert sorted(kwargs["TagFilters"], key=lambda x: x["Key"]) == [
        {"Key": "prefect:flow-id", "Values": ["flow-id"]},
        {"Key": "prefect:flow-version", "Values": ["1"]},
    ]
    assert kwargs["ResourceTypeFilters"] == ["ecs:task-definition"]