Merge pull request #390 from jotes/iam_sns_server

Added server backends with tests for IAM and SNS services.
This commit is contained in:
Steve Pulec 2015-08-03 18:58:53 -04:00
commit ed38a296db
6 changed files with 86 additions and 20 deletions

View file

@ -19,23 +19,13 @@ def test_cloudformation_server_get():
template_body = {
"Resources": {},
}
res = test_client.get(
'/?{0}'.format(
urlencode({
"Action": "CreateStack",
"StackName": stack_name,
"TemplateBody": json.dumps(template_body)
})
),
headers={"Host": "cloudformation.us-east-1.amazonaws.com"}
)
stack_id = json.loads(res.data.decode("utf-8"))["CreateStackResponse"]["CreateStackResult"]["StackId"]
res = test_client.action_json("CreateStack", StackName=stack_name,
TemplateBody=json.dumps(template_body))
stack_id = res["CreateStackResponse"]["CreateStackResult"]["StackId"]
res = test_client.get(
'/?Action=ListStacks',
headers={"Host": "cloudformation.us-east-1.amazonaws.com"}
)
stacks = re.search("<StackId>(.*)</StackId>", res.data.decode('utf-8'))
data = test_client.action_data("ListStacks")
stacks = re.search("<StackId>(.*)</StackId>", data)
list_stack_id = stacks.groups()[0]
assert stack_id == list_stack_id

View file

@ -0,0 +1,25 @@
from __future__ import unicode_literals
import json
import re
import sure # noqa
import moto.server as server
'''
Test the different server responses
'''
def test_iam_server_get():
backend = server.create_backend_app("iam")
test_client = backend.test_client()
group_data = test_client.action_data("CreateGroup", GroupName="test group", Path="/")
group_id = re.search("<GroupId>(.*)</GroupId>", group_data).groups()[0]
groups_data = test_client.action_data("ListGroups")
groups_ids = re.findall("<GroupId>(.*)</GroupId>", groups_data)
assert group_id in groups_ids

View file

@ -1 +1,24 @@
from __future__ import unicode_literals
import json
import re
import sure # noqa
import moto.server as server
'''
Test the different server responses
'''
def test_sns_server_get():
backend = server.create_backend_app("sns")
test_client = backend.test_client()
topic_data = test_client.action_json("CreateTopic", Name="test topic")
topic_arn = topic_data["CreateTopicResponse"]["CreateTopicResult"]["TopicArn"]
topics_data = test_client.action_json("ListTopics")
topics_arns = [t["TopicArn"] for t in topics_data["ListTopicsResponse"]["ListTopicsResult"]["Topics"]]
assert topic_arn in topics_arns