Prepare SWF objects representations directly via json.dumps()
... instead of jinja2 templates that are absolutely not suited for this purpose, and hard to test.
This commit is contained in:
parent
6e6b325225
commit
9483355584
4 changed files with 164 additions and 107 deletions
|
|
@ -3,6 +3,7 @@ from nose.tools import assert_raises
|
|||
from sure import expect
|
||||
|
||||
from moto import mock_swf
|
||||
from moto.swf.models import ActivityType
|
||||
from moto.swf.exceptions import (
|
||||
SWFUnknownResourceFault,
|
||||
SWFTypeAlreadyExistsFault,
|
||||
|
|
@ -11,6 +12,37 @@ from moto.swf.exceptions import (
|
|||
)
|
||||
|
||||
|
||||
# Models
|
||||
def test_short_dict_representation():
|
||||
_type = ActivityType("test-activity", "v1.0")
|
||||
_type.to_short_dict().should.equal({"name": "test-activity", "version": "v1.0"})
|
||||
|
||||
def test_medium_dict_representation():
|
||||
_type = ActivityType("test-activity", "v1.0")
|
||||
_type.to_medium_dict()["activityType"].should.equal(_type.to_short_dict())
|
||||
_type.to_medium_dict()["status"].should.equal("REGISTERED")
|
||||
_type.to_medium_dict().should.contain("creationDate")
|
||||
_type.to_medium_dict().should_not.contain("deprecationDate")
|
||||
_type.to_medium_dict().should_not.contain("description")
|
||||
|
||||
_type.description = "foo bar"
|
||||
_type.to_medium_dict()["description"].should.equal("foo bar")
|
||||
|
||||
_type.status = "DEPRECATED"
|
||||
_type.to_medium_dict().should.contain("deprecationDate")
|
||||
|
||||
def test_full_dict_representation():
|
||||
_type = ActivityType("test-activity", "v1.0")
|
||||
_type.to_full_dict()["typeInfo"].should.equal(_type.to_medium_dict())
|
||||
_type.to_full_dict()["configuration"].should.equal({})
|
||||
|
||||
_type.task_list = "foo"
|
||||
_type.to_full_dict()["configuration"]["defaultTaskList"].should.equal({"name":"foo"})
|
||||
|
||||
_type.default_task_heartbeat_timeout = "60"
|
||||
_type.to_full_dict()["configuration"]["defaultTaskHeartbeatTimeout"].should.equal("60")
|
||||
|
||||
|
||||
# RegisterActivityType endpoint
|
||||
@mock_swf
|
||||
def test_register_activity_type():
|
||||
|
|
@ -138,7 +170,6 @@ def test_describe_activity_type():
|
|||
|
||||
actype = conn.describe_activity_type("test-domain", "test-activity", "v1.0")
|
||||
actype["configuration"]["defaultTaskList"]["name"].should.equal("foo")
|
||||
actype["configuration"].keys().should_not.contain("defaultTaskScheduleToClose")
|
||||
infos = actype["typeInfo"]
|
||||
infos["activityType"]["name"].should.equal("test-activity")
|
||||
infos["activityType"]["version"].should.equal("v1.0")
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from nose.tools import assert_raises
|
|||
from sure import expect
|
||||
|
||||
from moto import mock_swf
|
||||
from moto.swf.models import Domain
|
||||
from moto.swf.exceptions import (
|
||||
SWFUnknownResourceFault,
|
||||
SWFDomainAlreadyExistsFault,
|
||||
|
|
@ -11,6 +12,15 @@ from moto.swf.exceptions import (
|
|||
)
|
||||
|
||||
|
||||
# Models
|
||||
def test_dict_representation():
|
||||
domain = Domain("foo", "52")
|
||||
domain.to_dict().should.equal({"name":"foo", "status":"REGISTERED"})
|
||||
|
||||
domain.description = "foo bar"
|
||||
domain.to_dict()["description"].should.equal("foo bar")
|
||||
|
||||
|
||||
# RegisterDomain endpoint
|
||||
@mock_swf
|
||||
def test_register_domain():
|
||||
|
|
@ -53,7 +63,7 @@ def test_register_with_wrong_parameter_type():
|
|||
ex.body["__type"].should.equal("com.amazonaws.swf.base.model#SerializationException")
|
||||
|
||||
|
||||
# ListDomain endpoint
|
||||
# ListDomains endpoint
|
||||
@mock_swf
|
||||
def test_list_domains_order():
|
||||
conn = boto.connect_swf("the_key", "the_secret")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue