diff --git a/moto/swf/models.py b/moto/swf/models.py index 921b0d97c..6fe724038 100644 --- a/moto/swf/models.py +++ b/moto/swf/models.py @@ -38,7 +38,7 @@ class Domain(object): def __repr__(self): return "Domain(name: %(name)s, status: %(status)s)" % self.__dict__ - def to_dict(self): + def to_short_dict(self): hsh = { "name": self.name, "status": self.status, @@ -47,6 +47,14 @@ class Domain(object): hsh["description"] = self.description return hsh + def to_full_dict(self): + return { + "domainInfo": self.to_short_dict(), + "configuration": { + "workflowExecutionRetentionPeriodInDays": self.retention, + } + } + def get_type(self, kind, name, version, ignore_empty=False): try: return self.types[kind][name][version] diff --git a/moto/swf/responses.py b/moto/swf/responses.py index 8e37cbaea..105db4c06 100644 --- a/moto/swf/responses.py +++ b/moto/swf/responses.py @@ -83,7 +83,7 @@ class SWFResponse(BaseResponse): reverse_order = self._params.get("reverseOrder", None) domains = self.swf_backend.list_domains(status, reverse_order=reverse_order) return json.dumps({ - "domainInfos": [domain.to_dict() for domain in domains] + "domainInfos": [domain.to_short_dict() for domain in domains] }) def register_domain(self): @@ -102,10 +102,7 @@ class SWFResponse(BaseResponse): def describe_domain(self): name = self._params["name"] domain = self.swf_backend.describe_domain(name) - return json.dumps({ - "configuration": { "workflowExecutionRetentionPeriodInDays": domain.retention }, - "domainInfo": domain.to_dict() - }) + return json.dumps(domain.to_full_dict()) # TODO: implement pagination def list_activity_types(self): diff --git a/tests/test_swf/test_models.py b/tests/test_swf/test_models.py index 67b6f6dca..7f636673c 100644 --- a/tests/test_swf/test_models.py +++ b/tests/test_swf/test_models.py @@ -8,12 +8,19 @@ from moto.swf.models import ( # Domain -def test_domain_dict_representation(): +def test_domain_short_dict_representation(): domain = Domain("foo", "52") - domain.to_dict().should.equal({"name":"foo", "status":"REGISTERED"}) + domain.to_short_dict().should.equal({"name":"foo", "status":"REGISTERED"}) domain.description = "foo bar" - domain.to_dict()["description"].should.equal("foo bar") + domain.to_short_dict()["description"].should.equal("foo bar") + +def test_domain_full_dict_representation(): + domain = Domain("foo", "52") + + domain.to_full_dict()["domainInfo"].should.equal(domain.to_short_dict()) + _config = domain.to_full_dict()["configuration"] + _config["workflowExecutionRetentionPeriodInDays"].should.equal("52") def test_domain_string_representation(): domain = Domain("my-domain", "60")