moto/tests/test_ec2/test_server.py

26 lines
640 B
Python
Raw Normal View History

from __future__ import unicode_literals
2013-03-05 13:14:43 +00:00
import re
2013-08-03 21:21:25 +00:00
import sure # noqa
2013-03-05 13:14:43 +00:00
import moto.server as server
2019-10-31 15:44:26 +00:00
"""
2013-03-05 13:14:43 +00:00
Test the different server responses
2019-10-31 15:44:26 +00:00
"""
2013-03-05 13:14:43 +00:00
def test_ec2_server_get():
2013-12-29 01:15:37 +00:00
backend = server.create_backend_app("ec2")
test_client = backend.test_client()
res = test_client.get(
2019-10-31 15:44:26 +00:00
"/?Action=RunInstances&ImageId=ami-60a54009",
headers={"Host": "ec2.us-east-1.amazonaws.com"},
)
2013-03-05 13:14:43 +00:00
2019-10-31 15:44:26 +00:00
groups = re.search("<instanceId>(.*)</instanceId>", res.data.decode("utf-8"))
2013-03-05 13:14:43 +00:00
instance_id = groups.groups()[0]
2019-10-31 15:44:26 +00:00
res = test_client.get("/?Action=DescribeInstances")
res.data.decode("utf-8").should.contain(instance_id)