Get standalone server mode working for all tests.
This commit is contained in:
parent
cb28eeefbb
commit
81836b6981
78 changed files with 957 additions and 783 deletions
|
|
@ -3,18 +3,23 @@ import sure # noqa
|
|||
from nose.tools import assert_raises
|
||||
import requests
|
||||
|
||||
from moto import mock_ec2
|
||||
from moto import mock_ec2, settings
|
||||
|
||||
if settings.TEST_SERVER_MODE:
|
||||
BASE_URL = 'http://localhost:8086'
|
||||
else:
|
||||
BASE_URL = 'http://169.254.169.254'
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_latest_meta_data():
|
||||
res = requests.get("http://169.254.169.254/latest/meta-data/")
|
||||
res = requests.get("{0}/latest/meta-data/".format(BASE_URL))
|
||||
res.content.should.equal(b"iam")
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_meta_data_iam():
|
||||
res = requests.get("http://169.254.169.254/latest/meta-data/iam")
|
||||
res = requests.get("{0}/latest/meta-data/iam".format(BASE_URL))
|
||||
json_response = res.json()
|
||||
default_role = json_response['security-credentials']['default-role']
|
||||
default_role.should.contain('AccessKeyId')
|
||||
|
|
@ -25,21 +30,15 @@ def test_meta_data_iam():
|
|||
|
||||
@mock_ec2
|
||||
def test_meta_data_security_credentials():
|
||||
res = requests.get("http://169.254.169.254/latest/meta-data/iam/security-credentials/")
|
||||
res = requests.get("{0}/latest/meta-data/iam/security-credentials/".format(BASE_URL))
|
||||
res.content.should.equal(b"default-role")
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_meta_data_default_role():
|
||||
res = requests.get("http://169.254.169.254/latest/meta-data/iam/security-credentials/default-role")
|
||||
res = requests.get("{0}/latest/meta-data/iam/security-credentials/default-role".format(BASE_URL))
|
||||
json_response = res.json()
|
||||
json_response.should.contain('AccessKeyId')
|
||||
json_response.should.contain('SecretAccessKey')
|
||||
json_response.should.contain('Token')
|
||||
json_response.should.contain('Expiration')
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_meta_data_unknown_path():
|
||||
with assert_raises(NotImplementedError):
|
||||
requests.get("http://169.254.169.254/latest/meta-data/badpath")
|
||||
|
|
|
|||
21
tests/test_core/test_moto_api.py
Normal file
21
tests/test_core/test_moto_api.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from __future__ import unicode_literals
|
||||
import sure # noqa
|
||||
from nose.tools import assert_raises
|
||||
import requests
|
||||
|
||||
import boto3
|
||||
from moto import mock_sqs, settings
|
||||
|
||||
base_url = "http://localhost:8086" if settings.TEST_SERVER_MODE else "http://motoapi.amazonaws.com"
|
||||
|
||||
|
||||
@mock_sqs
|
||||
def test_reset_api():
|
||||
conn = boto3.client("sqs", region_name='us-west-1')
|
||||
conn.create_queue(QueueName="queue1")
|
||||
conn.list_queues()['QueueUrls'].should.have.length_of(1)
|
||||
|
||||
res = requests.post("{base_url}/moto-api/reset".format(base_url=base_url))
|
||||
res.content.should.equal(b'{"status": "ok"}')
|
||||
|
||||
conn.list_queues().shouldnt.contain('QueueUrls') # No more queues
|
||||
Loading…
Add table
Add a link
Reference in a new issue