File: test_server.py

package info (click to toggle)
python-moto 5.1.18-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 116,520 kB
  • sloc: python: 636,725; javascript: 181; makefile: 39; sh: 3
file content (30 lines) | stat: -rw-r--r-- 875 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import json
import re

import moto.server as server

"""
Test the different server responses
"""


def test_cloudformation_server_get():
    backend = server.create_backend_app("cloudformation")
    stack_name = "test stack"
    test_client = backend.test_client()
    template_body = {"Resources": {}}
    create_stack_resp = test_client.action_data(
        "CreateStack", StackName=stack_name, TemplateBody=json.dumps(template_body)
    )
    assert "</CreateStackResponse>" in create_stack_resp
    assert "<StackId>" in create_stack_resp
    stack_id_from_create = re.search(
        "<StackId>(.*)</StackId>", create_stack_resp
    ).groups()[0]

    list_stacks_resp = test_client.action_data("ListStacks")
    stack_id_from_list = re.search(
        "<StackId>(.*)</StackId>", list_stacks_resp
    ).groups()[0]

    assert stack_id_from_create == stack_id_from_list