2015-08-02 14:27:08 +00:00
|
|
|
import json
|
|
|
|
import re
|
2021-10-18 19:44:29 +00:00
|
|
|
import sure # noqa # pylint: disable=unused-import
|
2015-08-02 14:27:08 +00:00
|
|
|
|
|
|
|
import moto.server as server
|
|
|
|
|
2019-10-31 15:44:26 +00:00
|
|
|
"""
|
2015-08-02 14:27:08 +00:00
|
|
|
Test the different server responses
|
2019-10-31 15:44:26 +00:00
|
|
|
"""
|
2015-08-02 14:27:08 +00:00
|
|
|
|
2015-08-02 15:37:10 +00:00
|
|
|
|
2015-08-02 14:27:08 +00:00
|
|
|
def test_cloudformation_server_get():
|
|
|
|
backend = server.create_backend_app("cloudformation")
|
2019-10-31 15:44:26 +00:00
|
|
|
stack_name = "test stack"
|
2015-08-03 20:48:15 +00:00
|
|
|
test_client = backend.test_client()
|
2019-10-31 15:44:26 +00:00
|
|
|
template_body = {"Resources": {}}
|
|
|
|
create_stack_resp = test_client.action_data(
|
|
|
|
"CreateStack", StackName=stack_name, TemplateBody=json.dumps(template_body)
|
|
|
|
)
|
2017-02-24 02:37:43 +00:00
|
|
|
create_stack_resp.should.match(
|
2019-10-31 15:44:26 +00:00
|
|
|
r"<CreateStackResponse>.*<CreateStackResult>.*<StackId>.*</StackId>.*</CreateStackResult>.*</CreateStackResponse>",
|
|
|
|
re.DOTALL,
|
|
|
|
)
|
2017-02-24 02:37:43 +00:00
|
|
|
stack_id_from_create_response = re.search(
|
2019-10-31 15:44:26 +00:00
|
|
|
"<StackId>(.*)</StackId>", create_stack_resp
|
|
|
|
).groups()[0]
|
2015-08-02 22:31:36 +00:00
|
|
|
|
2016-02-29 19:50:23 +00:00
|
|
|
list_stacks_resp = test_client.action_data("ListStacks")
|
2017-02-24 02:37:43 +00:00
|
|
|
stack_id_from_list_response = re.search(
|
2019-10-31 15:44:26 +00:00
|
|
|
"<StackId>(.*)</StackId>", list_stacks_resp
|
|
|
|
).groups()[0]
|
2015-08-02 22:31:36 +00:00
|
|
|
|
2016-02-29 19:50:23 +00:00
|
|
|
stack_id_from_create_response.should.equal(stack_id_from_list_response)
|