EMR and SWF - add arn to response (#3873)

* emr: add ClusterArn to describe_cluster response

* emr: add ClusterArn to list_clusters response

* emr: add ClusterArn to put_auto_scaling_policy response

* emr: add ClusterArn to run_job_flow response

* emr: rename property "cluster_arn" to simply "arn"

* emr: generalize arn for account_id and region

* swf: add arn to list_domains response

* black reformat source code

* fix double import

* swf: require region on Domain object

Co-authored-by: Kevin Neal <Kevin_Neal@intuit.com>
This commit is contained in:
khneal 2021-04-23 07:20:36 -07:00 committed by GitHub
commit 8b523c3fe1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 73 additions and 21 deletions

View file

@ -1,9 +1,11 @@
from collections import namedtuple
import sure # noqa
from moto.core import ACCOUNT_ID
from moto.swf.exceptions import SWFUnknownResourceFault
from moto.swf.models import Domain
TEST_REGION = "us-east-1"
# Fake WorkflowExecution for tests purposes
WorkflowExecution = namedtuple(
"WorkflowExecution", ["workflow_id", "run_id", "execution_status", "open"]
@ -11,15 +13,21 @@ WorkflowExecution = namedtuple(
def test_domain_short_dict_representation():
domain = Domain("foo", "52")
domain.to_short_dict().should.equal({"name": "foo", "status": "REGISTERED"})
domain = Domain("foo", "52", TEST_REGION)
domain.to_short_dict().should.equal(
{
"name": "foo",
"status": "REGISTERED",
"arn": "arn:aws:swf:{0}:{1}:/domain/foo".format(TEST_REGION, ACCOUNT_ID),
}
)
domain.description = "foo bar"
domain.to_short_dict()["description"].should.equal("foo bar")
def test_domain_full_dict_representation():
domain = Domain("foo", "52")
domain = Domain("foo", "52", TEST_REGION)
domain.to_full_dict()["domainInfo"].should.equal(domain.to_short_dict())
_config = domain.to_full_dict()["configuration"]
@ -27,38 +35,38 @@ def test_domain_full_dict_representation():
def test_domain_string_representation():
domain = Domain("my-domain", "60")
domain = Domain("my-domain", "60", TEST_REGION)
str(domain).should.equal("Domain(name: my-domain, status: REGISTERED)")
def test_domain_add_to_activity_task_list():
domain = Domain("my-domain", "60")
domain = Domain("my-domain", "60", TEST_REGION)
domain.add_to_activity_task_list("foo", "bar")
domain.activity_task_lists.should.equal({"foo": ["bar"]})
def test_domain_activity_tasks():
domain = Domain("my-domain", "60")
domain = Domain("my-domain", "60", TEST_REGION)
domain.add_to_activity_task_list("foo", "bar")
domain.add_to_activity_task_list("other", "baz")
sorted(domain.activity_tasks).should.equal(["bar", "baz"])
def test_domain_add_to_decision_task_list():
domain = Domain("my-domain", "60")
domain = Domain("my-domain", "60", TEST_REGION)
domain.add_to_decision_task_list("foo", "bar")
domain.decision_task_lists.should.equal({"foo": ["bar"]})
def test_domain_decision_tasks():
domain = Domain("my-domain", "60")
domain = Domain("my-domain", "60", TEST_REGION)
domain.add_to_decision_task_list("foo", "bar")
domain.add_to_decision_task_list("other", "baz")
sorted(domain.decision_tasks).should.equal(["bar", "baz"])
def test_domain_get_workflow_execution():
domain = Domain("my-domain", "60")
domain = Domain("my-domain", "60", TEST_REGION)
wfe1 = WorkflowExecution(
workflow_id="wf-id-1", run_id="run-id-1", execution_status="OPEN", open=True

View file

@ -6,6 +6,7 @@ import sure # noqa
from moto import mock_swf_deprecated
from moto import mock_swf
from moto.core import ACCOUNT_ID
# RegisterDomain endpoint
@ -20,6 +21,9 @@ def test_register_domain():
domain["name"].should.equal("test-domain")
domain["status"].should.equal("REGISTERED")
domain["description"].should.equal("A test domain")
domain["arn"].should.equal(
"arn:aws:swf:us-east-1:{0}:/domain/test-domain".format(ACCOUNT_ID)
)
@mock_swf_deprecated

View file

@ -31,7 +31,7 @@ for key, value in ACTIVITY_TASK_TIMEOUTS.items():
# A test Domain
def get_basic_domain():
return Domain("test-domain", "90")
return Domain("test-domain", "90", "us-east-1")
# A test WorkflowType