Testing new version of decorator.

This commit is contained in:
Steve Pulec 2017-02-15 22:35:45 -05:00
commit fde721bed7
123 changed files with 2740 additions and 1114 deletions

View file

@ -2,11 +2,11 @@ from __future__ import unicode_literals
import boto
from boto.exception import BotoServerError
from moto import mock_sns
from moto import mock_sns_deprecated
import sure # noqa
@mock_sns
@mock_sns_deprecated
def test_create_platform_application():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -21,7 +21,7 @@ def test_create_platform_application():
application_arn.should.equal('arn:aws:sns:us-east-1:123456789012:app/APNS/my-application')
@mock_sns
@mock_sns_deprecated
def test_get_platform_application_attributes():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -40,13 +40,13 @@ def test_get_platform_application_attributes():
})
@mock_sns
@mock_sns_deprecated
def test_get_missing_platform_application_attributes():
conn = boto.connect_sns()
conn.get_platform_application_attributes.when.called_with("a-fake-arn").should.throw(BotoServerError)
@mock_sns
@mock_sns_deprecated
def test_set_platform_application_attributes():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -68,7 +68,7 @@ def test_set_platform_application_attributes():
})
@mock_sns
@mock_sns_deprecated
def test_list_platform_applications():
conn = boto.connect_sns()
conn.create_platform_application(
@ -85,7 +85,7 @@ def test_list_platform_applications():
applications.should.have.length_of(2)
@mock_sns
@mock_sns_deprecated
def test_delete_platform_application():
conn = boto.connect_sns()
conn.create_platform_application(
@ -109,7 +109,7 @@ def test_delete_platform_application():
applications.should.have.length_of(1)
@mock_sns
@mock_sns_deprecated
def test_create_platform_endpoint():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -131,7 +131,7 @@ def test_create_platform_endpoint():
endpoint_arn.should.contain("arn:aws:sns:us-east-1:123456789012:endpoint/APNS/my-application/")
@mock_sns
@mock_sns_deprecated
def test_get_list_endpoints_by_platform_application():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -159,7 +159,7 @@ def test_get_list_endpoints_by_platform_application():
endpoint_list[0]['EndpointArn'].should.equal(endpoint_arn)
@mock_sns
@mock_sns_deprecated
def test_get_endpoint_attributes():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -187,13 +187,13 @@ def test_get_endpoint_attributes():
})
@mock_sns
@mock_sns_deprecated
def test_get_missing_endpoint_attributes():
conn = boto.connect_sns()
conn.get_endpoint_attributes.when.called_with("a-fake-arn").should.throw(BotoServerError)
@mock_sns
@mock_sns_deprecated
def test_set_endpoint_attributes():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -224,7 +224,7 @@ def test_set_endpoint_attributes():
})
@mock_sns
@mock_sns_deprecated
def test_delete_endpoint():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -258,7 +258,7 @@ def test_delete_endpoint():
endpoint_list.should.have.length_of(0)
@mock_sns
@mock_sns_deprecated
def test_publish_to_platform_endpoint():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(

View file

@ -3,14 +3,14 @@ from six.moves.urllib.parse import parse_qs
import boto
from freezegun import freeze_time
import httpretty
import sure # noqa
from moto import mock_sns, mock_sqs
from moto.packages.responses import responses
from moto import mock_sns, mock_sns_deprecated, mock_sqs_deprecated
@mock_sqs
@mock_sns
@mock_sqs_deprecated
@mock_sns_deprecated
def test_publish_to_sqs():
conn = boto.connect_sns()
conn.create_topic("some-topic")
@ -29,8 +29,8 @@ def test_publish_to_sqs():
message.get_body().should.equal('my message')
@mock_sqs
@mock_sns
@mock_sqs_deprecated
@mock_sns_deprecated
def test_publish_to_sqs_in_different_region():
conn = boto.sns.connect_to_region("us-west-1")
conn.create_topic("some-topic")
@ -51,10 +51,11 @@ def test_publish_to_sqs_in_different_region():
@freeze_time("2013-01-01")
@mock_sns
@mock_sns_deprecated
def test_publish_to_http():
httpretty.HTTPretty.register_uri(
responses.add(
method="POST",
uri="http://example.com/foobar",
url="http://example.com/foobar",
)
conn = boto.connect_sns()
@ -67,7 +68,7 @@ def test_publish_to_http():
response = conn.publish(topic=topic_arn, message="my message", subject="my subject")
message_id = response['PublishResponse']['PublishResult']['MessageId']
last_request = httpretty.last_request()
last_request = responses.calls[-1].request
last_request.method.should.equal("POST")
parse_qs(last_request.body.decode('utf-8')).should.equal({
"Type": ["Notification"],
@ -81,3 +82,5 @@ def test_publish_to_http():
"SigningCertURL": ["https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem"],
"UnsubscribeURL": ["https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:123456789012:some-topic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"],
})

View file

@ -3,9 +3,9 @@ from six.moves.urllib.parse import parse_qs
import boto3
from freezegun import freeze_time
import httpretty
import sure # noqa
from moto.packages.responses import responses
from moto import mock_sns, mock_sqs
@ -56,9 +56,9 @@ def test_publish_to_sqs_in_different_region():
@freeze_time("2013-01-01")
@mock_sns
def test_publish_to_http():
httpretty.HTTPretty.register_uri(
responses.add(
method="POST",
uri="http://example.com/foobar",
url="http://example.com/foobar",
)
conn = boto3.client('sns', region_name='us-east-1')
@ -73,7 +73,7 @@ def test_publish_to_http():
response = conn.publish(TopicArn=topic_arn, Message="my message", Subject="my subject")
message_id = response['MessageId']
last_request = httpretty.last_request()
last_request = responses.calls[-2].request
last_request.method.should.equal("POST")
parse_qs(last_request.body.decode('utf-8')).should.equal({
"Type": ["Notification"],

View file

@ -3,11 +3,11 @@ import boto
import sure # noqa
from moto import mock_sns
from moto import mock_sns_deprecated
from moto.sns.models import DEFAULT_PAGE_SIZE
@mock_sns
@mock_sns_deprecated
def test_creating_subscription():
conn = boto.connect_sns()
conn.create_topic("some-topic")
@ -32,7 +32,7 @@ def test_creating_subscription():
subscriptions.should.have.length_of(0)
@mock_sns
@mock_sns_deprecated
def test_getting_subscriptions_by_topic():
conn = boto.connect_sns()
conn.create_topic("topic1")
@ -51,7 +51,7 @@ def test_getting_subscriptions_by_topic():
topic1_subscriptions[0]['Endpoint'].should.equal("http://example1.com/")
@mock_sns
@mock_sns_deprecated
def test_subscription_paging():
conn = boto.connect_sns()
conn.create_topic("topic1")

View file

@ -5,11 +5,11 @@ import six
import sure # noqa
from boto.exception import BotoServerError
from moto import mock_sns
from moto import mock_sns_deprecated
from moto.sns.models import DEFAULT_TOPIC_POLICY, DEFAULT_EFFECTIVE_DELIVERY_POLICY, DEFAULT_PAGE_SIZE
@mock_sns
@mock_sns_deprecated
def test_create_and_delete_topic():
conn = boto.connect_sns()
conn.create_topic("some-topic")
@ -31,20 +31,20 @@ def test_create_and_delete_topic():
topics.should.have.length_of(0)
@mock_sns
@mock_sns_deprecated
def test_get_missing_topic():
conn = boto.connect_sns()
conn.get_topic_attributes.when.called_with("a-fake-arn").should.throw(BotoServerError)
@mock_sns
@mock_sns_deprecated
def test_create_topic_in_multiple_regions():
for region in ['us-west-1', 'us-west-2']:
conn = boto.sns.connect_to_region(region)
conn.create_topic("some-topic")
list(conn.get_all_topics()["ListTopicsResponse"]["ListTopicsResult"]["Topics"]).should.have.length_of(1)
@mock_sns
@mock_sns_deprecated
def test_topic_corresponds_to_region():
for region in ['us-east-1', 'us-west-2']:
conn = boto.sns.connect_to_region(region)
@ -53,7 +53,7 @@ def test_topic_corresponds_to_region():
topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0]['TopicArn']
topic_arn.should.equal("arn:aws:sns:{0}:123456789012:some-topic".format(region))
@mock_sns
@mock_sns_deprecated
def test_topic_attributes():
conn = boto.connect_sns()
conn.create_topic("some-topic")
@ -95,7 +95,7 @@ def test_topic_attributes():
attributes["DisplayName"].should.equal("My display name")
attributes["DeliveryPolicy"].should.equal("{'http': {'defaultHealthyRetryPolicy': {'numRetries': 5}}}")
@mock_sns
@mock_sns_deprecated
def test_topic_paging():
conn = boto.connect_sns()
for index in range(DEFAULT_PAGE_SIZE + int(DEFAULT_PAGE_SIZE / 2)):