Move SWF Domain full dict representation to model
This commit is contained in:
parent
92cf64c2ad
commit
c08c20d197
@ -38,7 +38,7 @@ class Domain(object):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "Domain(name: %(name)s, status: %(status)s)" % self.__dict__
|
return "Domain(name: %(name)s, status: %(status)s)" % self.__dict__
|
||||||
|
|
||||||
def to_dict(self):
|
def to_short_dict(self):
|
||||||
hsh = {
|
hsh = {
|
||||||
"name": self.name,
|
"name": self.name,
|
||||||
"status": self.status,
|
"status": self.status,
|
||||||
@ -47,6 +47,14 @@ class Domain(object):
|
|||||||
hsh["description"] = self.description
|
hsh["description"] = self.description
|
||||||
return hsh
|
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):
|
def get_type(self, kind, name, version, ignore_empty=False):
|
||||||
try:
|
try:
|
||||||
return self.types[kind][name][version]
|
return self.types[kind][name][version]
|
||||||
|
@ -83,7 +83,7 @@ class SWFResponse(BaseResponse):
|
|||||||
reverse_order = self._params.get("reverseOrder", None)
|
reverse_order = self._params.get("reverseOrder", None)
|
||||||
domains = self.swf_backend.list_domains(status, reverse_order=reverse_order)
|
domains = self.swf_backend.list_domains(status, reverse_order=reverse_order)
|
||||||
return json.dumps({
|
return json.dumps({
|
||||||
"domainInfos": [domain.to_dict() for domain in domains]
|
"domainInfos": [domain.to_short_dict() for domain in domains]
|
||||||
})
|
})
|
||||||
|
|
||||||
def register_domain(self):
|
def register_domain(self):
|
||||||
@ -102,10 +102,7 @@ class SWFResponse(BaseResponse):
|
|||||||
def describe_domain(self):
|
def describe_domain(self):
|
||||||
name = self._params["name"]
|
name = self._params["name"]
|
||||||
domain = self.swf_backend.describe_domain(name)
|
domain = self.swf_backend.describe_domain(name)
|
||||||
return json.dumps({
|
return json.dumps(domain.to_full_dict())
|
||||||
"configuration": { "workflowExecutionRetentionPeriodInDays": domain.retention },
|
|
||||||
"domainInfo": domain.to_dict()
|
|
||||||
})
|
|
||||||
|
|
||||||
# TODO: implement pagination
|
# TODO: implement pagination
|
||||||
def list_activity_types(self):
|
def list_activity_types(self):
|
||||||
|
@ -8,12 +8,19 @@ from moto.swf.models import (
|
|||||||
|
|
||||||
|
|
||||||
# Domain
|
# Domain
|
||||||
def test_domain_dict_representation():
|
def test_domain_short_dict_representation():
|
||||||
domain = Domain("foo", "52")
|
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.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():
|
def test_domain_string_representation():
|
||||||
domain = Domain("my-domain", "60")
|
domain = Domain("my-domain", "60")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user