Lints.
This commit is contained in:
parent
1433f28846
commit
f37bad0e00
260 changed files with 6363 additions and 3766 deletions
|
|
@ -17,8 +17,10 @@ def test_create_platform_application():
|
|||
"PlatformPrincipal": "platform_principal",
|
||||
},
|
||||
)
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
application_arn.should.equal('arn:aws:sns:us-east-1:123456789012:app/APNS/my-application')
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse'][
|
||||
'CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
application_arn.should.equal(
|
||||
'arn:aws:sns:us-east-1:123456789012:app/APNS/my-application')
|
||||
|
||||
|
||||
@mock_sns_deprecated
|
||||
|
|
@ -32,8 +34,10 @@ def test_get_platform_application_attributes():
|
|||
"PlatformPrincipal": "platform_principal",
|
||||
},
|
||||
)
|
||||
arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
attributes = conn.get_platform_application_attributes(arn)['GetPlatformApplicationAttributesResponse']['GetPlatformApplicationAttributesResult']['Attributes']
|
||||
arn = platform_application['CreatePlatformApplicationResponse'][
|
||||
'CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
attributes = conn.get_platform_application_attributes(arn)['GetPlatformApplicationAttributesResponse'][
|
||||
'GetPlatformApplicationAttributesResult']['Attributes']
|
||||
attributes.should.equal({
|
||||
"PlatformCredential": "platform_credential",
|
||||
"PlatformPrincipal": "platform_principal",
|
||||
|
|
@ -43,7 +47,8 @@ def test_get_platform_application_attributes():
|
|||
@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)
|
||||
conn.get_platform_application_attributes.when.called_with(
|
||||
"a-fake-arn").should.throw(BotoServerError)
|
||||
|
||||
|
||||
@mock_sns_deprecated
|
||||
|
|
@ -57,11 +62,13 @@ def test_set_platform_application_attributes():
|
|||
"PlatformPrincipal": "platform_principal",
|
||||
},
|
||||
)
|
||||
arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
arn = platform_application['CreatePlatformApplicationResponse'][
|
||||
'CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
conn.set_platform_application_attributes(arn,
|
||||
{"PlatformPrincipal": "other"}
|
||||
)
|
||||
attributes = conn.get_platform_application_attributes(arn)['GetPlatformApplicationAttributesResponse']['GetPlatformApplicationAttributesResult']['Attributes']
|
||||
{"PlatformPrincipal": "other"}
|
||||
)
|
||||
attributes = conn.get_platform_application_attributes(arn)['GetPlatformApplicationAttributesResponse'][
|
||||
'GetPlatformApplicationAttributesResult']['Attributes']
|
||||
attributes.should.equal({
|
||||
"PlatformCredential": "platform_credential",
|
||||
"PlatformPrincipal": "other",
|
||||
|
|
@ -81,7 +88,8 @@ def test_list_platform_applications():
|
|||
)
|
||||
|
||||
applications_repsonse = conn.list_platform_applications()
|
||||
applications = applications_repsonse['ListPlatformApplicationsResponse']['ListPlatformApplicationsResult']['PlatformApplications']
|
||||
applications = applications_repsonse['ListPlatformApplicationsResponse'][
|
||||
'ListPlatformApplicationsResult']['PlatformApplications']
|
||||
applications.should.have.length_of(2)
|
||||
|
||||
|
||||
|
|
@ -98,14 +106,16 @@ def test_delete_platform_application():
|
|||
)
|
||||
|
||||
applications_repsonse = conn.list_platform_applications()
|
||||
applications = applications_repsonse['ListPlatformApplicationsResponse']['ListPlatformApplicationsResult']['PlatformApplications']
|
||||
applications = applications_repsonse['ListPlatformApplicationsResponse'][
|
||||
'ListPlatformApplicationsResult']['PlatformApplications']
|
||||
applications.should.have.length_of(2)
|
||||
|
||||
application_arn = applications[0]['PlatformApplicationArn']
|
||||
conn.delete_platform_application(application_arn)
|
||||
|
||||
applications_repsonse = conn.list_platform_applications()
|
||||
applications = applications_repsonse['ListPlatformApplicationsResponse']['ListPlatformApplicationsResult']['PlatformApplications']
|
||||
applications = applications_repsonse['ListPlatformApplicationsResponse'][
|
||||
'ListPlatformApplicationsResult']['PlatformApplications']
|
||||
applications.should.have.length_of(1)
|
||||
|
||||
|
||||
|
|
@ -116,7 +126,8 @@ def test_create_platform_endpoint():
|
|||
name="my-application",
|
||||
platform="APNS",
|
||||
)
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse'][
|
||||
'CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
|
||||
endpoint = conn.create_platform_endpoint(
|
||||
platform_application_arn=application_arn,
|
||||
|
|
@ -127,8 +138,10 @@ def test_create_platform_endpoint():
|
|||
},
|
||||
)
|
||||
|
||||
endpoint_arn = endpoint['CreatePlatformEndpointResponse']['CreatePlatformEndpointResult']['EndpointArn']
|
||||
endpoint_arn.should.contain("arn:aws:sns:us-east-1:123456789012:endpoint/APNS/my-application/")
|
||||
endpoint_arn = endpoint['CreatePlatformEndpointResponse'][
|
||||
'CreatePlatformEndpointResult']['EndpointArn']
|
||||
endpoint_arn.should.contain(
|
||||
"arn:aws:sns:us-east-1:123456789012:endpoint/APNS/my-application/")
|
||||
|
||||
|
||||
@mock_sns_deprecated
|
||||
|
|
@ -138,7 +151,8 @@ def test_get_list_endpoints_by_platform_application():
|
|||
name="my-application",
|
||||
platform="APNS",
|
||||
)
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse'][
|
||||
'CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
|
||||
endpoint = conn.create_platform_endpoint(
|
||||
platform_application_arn=application_arn,
|
||||
|
|
@ -148,7 +162,8 @@ def test_get_list_endpoints_by_platform_application():
|
|||
"CustomUserData": "some data",
|
||||
},
|
||||
)
|
||||
endpoint_arn = endpoint['CreatePlatformEndpointResponse']['CreatePlatformEndpointResult']['EndpointArn']
|
||||
endpoint_arn = endpoint['CreatePlatformEndpointResponse'][
|
||||
'CreatePlatformEndpointResult']['EndpointArn']
|
||||
|
||||
endpoint_list = conn.list_endpoints_by_platform_application(
|
||||
platform_application_arn=application_arn
|
||||
|
|
@ -166,7 +181,8 @@ def test_get_endpoint_attributes():
|
|||
name="my-application",
|
||||
platform="APNS",
|
||||
)
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse'][
|
||||
'CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
|
||||
endpoint = conn.create_platform_endpoint(
|
||||
platform_application_arn=application_arn,
|
||||
|
|
@ -177,9 +193,11 @@ def test_get_endpoint_attributes():
|
|||
"CustomUserData": "some data",
|
||||
},
|
||||
)
|
||||
endpoint_arn = endpoint['CreatePlatformEndpointResponse']['CreatePlatformEndpointResult']['EndpointArn']
|
||||
endpoint_arn = endpoint['CreatePlatformEndpointResponse'][
|
||||
'CreatePlatformEndpointResult']['EndpointArn']
|
||||
|
||||
attributes = conn.get_endpoint_attributes(endpoint_arn)['GetEndpointAttributesResponse']['GetEndpointAttributesResult']['Attributes']
|
||||
attributes = conn.get_endpoint_attributes(endpoint_arn)['GetEndpointAttributesResponse'][
|
||||
'GetEndpointAttributesResult']['Attributes']
|
||||
attributes.should.equal({
|
||||
"Token": "some_unique_id",
|
||||
"Enabled": 'False',
|
||||
|
|
@ -190,7 +208,8 @@ def test_get_endpoint_attributes():
|
|||
@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)
|
||||
conn.get_endpoint_attributes.when.called_with(
|
||||
"a-fake-arn").should.throw(BotoServerError)
|
||||
|
||||
|
||||
@mock_sns_deprecated
|
||||
|
|
@ -200,7 +219,8 @@ def test_set_endpoint_attributes():
|
|||
name="my-application",
|
||||
platform="APNS",
|
||||
)
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse'][
|
||||
'CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
|
||||
endpoint = conn.create_platform_endpoint(
|
||||
platform_application_arn=application_arn,
|
||||
|
|
@ -211,12 +231,14 @@ def test_set_endpoint_attributes():
|
|||
"CustomUserData": "some data",
|
||||
},
|
||||
)
|
||||
endpoint_arn = endpoint['CreatePlatformEndpointResponse']['CreatePlatformEndpointResult']['EndpointArn']
|
||||
endpoint_arn = endpoint['CreatePlatformEndpointResponse'][
|
||||
'CreatePlatformEndpointResult']['EndpointArn']
|
||||
|
||||
conn.set_endpoint_attributes(endpoint_arn,
|
||||
{"CustomUserData": "other data"}
|
||||
)
|
||||
attributes = conn.get_endpoint_attributes(endpoint_arn)['GetEndpointAttributesResponse']['GetEndpointAttributesResult']['Attributes']
|
||||
{"CustomUserData": "other data"}
|
||||
)
|
||||
attributes = conn.get_endpoint_attributes(endpoint_arn)['GetEndpointAttributesResponse'][
|
||||
'GetEndpointAttributesResult']['Attributes']
|
||||
attributes.should.equal({
|
||||
"Token": "some_unique_id",
|
||||
"Enabled": 'False',
|
||||
|
|
@ -231,7 +253,8 @@ def test_delete_endpoint():
|
|||
name="my-application",
|
||||
platform="APNS",
|
||||
)
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse'][
|
||||
'CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
|
||||
endpoint = conn.create_platform_endpoint(
|
||||
platform_application_arn=application_arn,
|
||||
|
|
@ -242,7 +265,8 @@ def test_delete_endpoint():
|
|||
"CustomUserData": "some data",
|
||||
},
|
||||
)
|
||||
endpoint_arn = endpoint['CreatePlatformEndpointResponse']['CreatePlatformEndpointResult']['EndpointArn']
|
||||
endpoint_arn = endpoint['CreatePlatformEndpointResponse'][
|
||||
'CreatePlatformEndpointResult']['EndpointArn']
|
||||
|
||||
endpoint_list = conn.list_endpoints_by_platform_application(
|
||||
platform_application_arn=application_arn
|
||||
|
|
@ -265,7 +289,8 @@ def test_publish_to_platform_endpoint():
|
|||
name="my-application",
|
||||
platform="APNS",
|
||||
)
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse']['CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
application_arn = platform_application['CreatePlatformApplicationResponse'][
|
||||
'CreatePlatformApplicationResult']['PlatformApplicationArn']
|
||||
|
||||
endpoint = conn.create_platform_endpoint(
|
||||
platform_application_arn=application_arn,
|
||||
|
|
@ -276,6 +301,8 @@ def test_publish_to_platform_endpoint():
|
|||
},
|
||||
)
|
||||
|
||||
endpoint_arn = endpoint['CreatePlatformEndpointResponse']['CreatePlatformEndpointResult']['EndpointArn']
|
||||
endpoint_arn = endpoint['CreatePlatformEndpointResponse'][
|
||||
'CreatePlatformEndpointResult']['EndpointArn']
|
||||
|
||||
conn.publish(message="some message", message_structure="json", target_arn=endpoint_arn)
|
||||
conn.publish(message="some message", message_structure="json",
|
||||
target_arn=endpoint_arn)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ def test_create_platform_application():
|
|||
},
|
||||
)
|
||||
application_arn = response['PlatformApplicationArn']
|
||||
application_arn.should.equal('arn:aws:sns:us-east-1:123456789012:app/APNS/my-application')
|
||||
application_arn.should.equal(
|
||||
'arn:aws:sns:us-east-1:123456789012:app/APNS/my-application')
|
||||
|
||||
|
||||
@mock_sns
|
||||
|
|
@ -33,7 +34,8 @@ def test_get_platform_application_attributes():
|
|||
},
|
||||
)
|
||||
arn = platform_application['PlatformApplicationArn']
|
||||
attributes = conn.get_platform_application_attributes(PlatformApplicationArn=arn)['Attributes']
|
||||
attributes = conn.get_platform_application_attributes(
|
||||
PlatformApplicationArn=arn)['Attributes']
|
||||
attributes.should.equal({
|
||||
"PlatformCredential": "platform_credential",
|
||||
"PlatformPrincipal": "platform_principal",
|
||||
|
|
@ -43,7 +45,8 @@ def test_get_platform_application_attributes():
|
|||
@mock_sns
|
||||
def test_get_missing_platform_application_attributes():
|
||||
conn = boto3.client('sns', region_name='us-east-1')
|
||||
conn.get_platform_application_attributes.when.called_with(PlatformApplicationArn="a-fake-arn").should.throw(ClientError)
|
||||
conn.get_platform_application_attributes.when.called_with(
|
||||
PlatformApplicationArn="a-fake-arn").should.throw(ClientError)
|
||||
|
||||
|
||||
@mock_sns
|
||||
|
|
@ -59,9 +62,11 @@ def test_set_platform_application_attributes():
|
|||
)
|
||||
arn = platform_application['PlatformApplicationArn']
|
||||
conn.set_platform_application_attributes(PlatformApplicationArn=arn,
|
||||
Attributes={"PlatformPrincipal": "other"}
|
||||
)
|
||||
attributes = conn.get_platform_application_attributes(PlatformApplicationArn=arn)['Attributes']
|
||||
Attributes={
|
||||
"PlatformPrincipal": "other"}
|
||||
)
|
||||
attributes = conn.get_platform_application_attributes(
|
||||
PlatformApplicationArn=arn)['Attributes']
|
||||
attributes.should.equal({
|
||||
"PlatformCredential": "platform_credential",
|
||||
"PlatformPrincipal": "other",
|
||||
|
|
@ -133,7 +138,8 @@ def test_create_platform_endpoint():
|
|||
)
|
||||
|
||||
endpoint_arn = endpoint['EndpointArn']
|
||||
endpoint_arn.should.contain("arn:aws:sns:us-east-1:123456789012:endpoint/APNS/my-application/")
|
||||
endpoint_arn.should.contain(
|
||||
"arn:aws:sns:us-east-1:123456789012:endpoint/APNS/my-application/")
|
||||
|
||||
|
||||
@mock_sns
|
||||
|
|
@ -186,7 +192,8 @@ def test_get_endpoint_attributes():
|
|||
)
|
||||
endpoint_arn = endpoint['EndpointArn']
|
||||
|
||||
attributes = conn.get_endpoint_attributes(EndpointArn=endpoint_arn)['Attributes']
|
||||
attributes = conn.get_endpoint_attributes(
|
||||
EndpointArn=endpoint_arn)['Attributes']
|
||||
attributes.should.equal({
|
||||
"Token": "some_unique_id",
|
||||
"Enabled": 'false',
|
||||
|
|
@ -197,7 +204,8 @@ def test_get_endpoint_attributes():
|
|||
@mock_sns
|
||||
def test_get_missing_endpoint_attributes():
|
||||
conn = boto3.client('sns', region_name='us-east-1')
|
||||
conn.get_endpoint_attributes.when.called_with(EndpointArn="a-fake-arn").should.throw(ClientError)
|
||||
conn.get_endpoint_attributes.when.called_with(
|
||||
EndpointArn="a-fake-arn").should.throw(ClientError)
|
||||
|
||||
|
||||
@mock_sns
|
||||
|
|
@ -222,9 +230,10 @@ def test_set_endpoint_attributes():
|
|||
endpoint_arn = endpoint['EndpointArn']
|
||||
|
||||
conn.set_endpoint_attributes(EndpointArn=endpoint_arn,
|
||||
Attributes={"CustomUserData": "other data"}
|
||||
)
|
||||
attributes = conn.get_endpoint_attributes(EndpointArn=endpoint_arn)['Attributes']
|
||||
Attributes={"CustomUserData": "other data"}
|
||||
)
|
||||
attributes = conn.get_endpoint_attributes(
|
||||
EndpointArn=endpoint_arn)['Attributes']
|
||||
attributes.should.equal({
|
||||
"Token": "some_unique_id",
|
||||
"Enabled": 'false',
|
||||
|
|
@ -253,4 +262,5 @@ def test_publish_to_platform_endpoint():
|
|||
|
||||
endpoint_arn = endpoint['EndpointArn']
|
||||
|
||||
conn.publish(Message="some message", MessageStructure="json", TargetArn=endpoint_arn)
|
||||
conn.publish(Message="some message",
|
||||
MessageStructure="json", TargetArn=endpoint_arn)
|
||||
|
|
|
|||
|
|
@ -15,12 +15,14 @@ def test_publish_to_sqs():
|
|||
conn = boto.connect_sns()
|
||||
conn.create_topic("some-topic")
|
||||
topics_json = conn.get_all_topics()
|
||||
topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0]['TopicArn']
|
||||
topic_arn = topics_json["ListTopicsResponse"][
|
||||
"ListTopicsResult"]["Topics"][0]['TopicArn']
|
||||
|
||||
sqs_conn = boto.connect_sqs()
|
||||
sqs_conn.create_queue("test-queue")
|
||||
|
||||
conn.subscribe(topic_arn, "sqs", "arn:aws:sqs:us-east-1:123456789012:test-queue")
|
||||
conn.subscribe(topic_arn, "sqs",
|
||||
"arn:aws:sqs:us-east-1:123456789012:test-queue")
|
||||
|
||||
conn.publish(topic=topic_arn, message="my message")
|
||||
|
||||
|
|
@ -35,12 +37,14 @@ def test_publish_to_sqs_in_different_region():
|
|||
conn = boto.sns.connect_to_region("us-west-1")
|
||||
conn.create_topic("some-topic")
|
||||
topics_json = conn.get_all_topics()
|
||||
topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0]['TopicArn']
|
||||
topic_arn = topics_json["ListTopicsResponse"][
|
||||
"ListTopicsResult"]["Topics"][0]['TopicArn']
|
||||
|
||||
sqs_conn = boto.sqs.connect_to_region("us-west-2")
|
||||
sqs_conn.create_queue("test-queue")
|
||||
|
||||
conn.subscribe(topic_arn, "sqs", "arn:aws:sqs:us-west-2:123456789012:test-queue")
|
||||
conn.subscribe(topic_arn, "sqs",
|
||||
"arn:aws:sqs:us-west-2:123456789012:test-queue")
|
||||
|
||||
conn.publish(topic=topic_arn, message="my message")
|
||||
|
||||
|
|
@ -61,9 +65,11 @@ def test_publish_to_http():
|
|||
conn = boto.connect_sns()
|
||||
conn.create_topic("some-topic")
|
||||
topics_json = conn.get_all_topics()
|
||||
topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0]['TopicArn']
|
||||
topic_arn = topics_json["ListTopicsResponse"][
|
||||
"ListTopicsResult"]["Topics"][0]['TopicArn']
|
||||
|
||||
conn.subscribe(topic_arn, "http", "http://example.com/foobar")
|
||||
|
||||
response = conn.publish(topic=topic_arn, message="my message", subject="my subject")
|
||||
response = conn.publish(
|
||||
topic=topic_arn, message="my message", subject="my subject")
|
||||
message_id = response['PublishResponse']['PublishResult']['MessageId']
|
||||
|
|
|
|||
|
|
@ -70,5 +70,6 @@ def test_publish_to_http():
|
|||
Protocol="http",
|
||||
Endpoint="http://example.com/foobar")
|
||||
|
||||
response = conn.publish(TopicArn=topic_arn, Message="my message", Subject="my subject")
|
||||
response = conn.publish(
|
||||
TopicArn=topic_arn, Message="my message", Subject="my subject")
|
||||
message_id = response['MessageId']
|
||||
|
|
|
|||
|
|
@ -15,8 +15,10 @@ def test_sns_server_get():
|
|||
|
||||
topic_data = test_client.action_data("CreateTopic", Name="test topic")
|
||||
topic_data.should.contain("CreateTopicResult")
|
||||
topic_data.should.contain("<TopicArn>arn:aws:sns:us-east-1:123456789012:test topic</TopicArn>")
|
||||
topic_data.should.contain(
|
||||
"<TopicArn>arn:aws:sns:us-east-1:123456789012:test topic</TopicArn>")
|
||||
|
||||
topics_data = test_client.action_data("ListTopics")
|
||||
topics_data.should.contain("ListTopicsResult")
|
||||
topic_data.should.contain("<TopicArn>arn:aws:sns:us-east-1:123456789012:test topic</TopicArn>")
|
||||
topic_data.should.contain(
|
||||
"<TopicArn>arn:aws:sns:us-east-1:123456789012:test topic</TopicArn>")
|
||||
|
|
|
|||
|
|
@ -12,11 +12,13 @@ def test_creating_subscription():
|
|||
conn = boto.connect_sns()
|
||||
conn.create_topic("some-topic")
|
||||
topics_json = conn.get_all_topics()
|
||||
topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0]['TopicArn']
|
||||
topic_arn = topics_json["ListTopicsResponse"][
|
||||
"ListTopicsResult"]["Topics"][0]['TopicArn']
|
||||
|
||||
conn.subscribe(topic_arn, "http", "http://example.com/")
|
||||
|
||||
subscriptions = conn.get_all_subscriptions()["ListSubscriptionsResponse"]["ListSubscriptionsResult"]["Subscriptions"]
|
||||
subscriptions = conn.get_all_subscriptions()["ListSubscriptionsResponse"][
|
||||
"ListSubscriptionsResult"]["Subscriptions"]
|
||||
subscriptions.should.have.length_of(1)
|
||||
subscription = subscriptions[0]
|
||||
subscription["TopicArn"].should.equal(topic_arn)
|
||||
|
|
@ -28,7 +30,8 @@ def test_creating_subscription():
|
|||
conn.unsubscribe(subscription["SubscriptionArn"])
|
||||
|
||||
# And there should be zero subscriptions left
|
||||
subscriptions = conn.get_all_subscriptions()["ListSubscriptionsResponse"]["ListSubscriptionsResult"]["Subscriptions"]
|
||||
subscriptions = conn.get_all_subscriptions()["ListSubscriptionsResponse"][
|
||||
"ListSubscriptionsResult"]["Subscriptions"]
|
||||
subscriptions.should.have.length_of(0)
|
||||
|
||||
|
||||
|
|
@ -46,7 +49,8 @@ def test_getting_subscriptions_by_topic():
|
|||
conn.subscribe(topic1_arn, "http", "http://example1.com/")
|
||||
conn.subscribe(topic2_arn, "http", "http://example2.com/")
|
||||
|
||||
topic1_subscriptions = conn.get_all_subscriptions_by_topic(topic1_arn)["ListSubscriptionsByTopicResponse"]["ListSubscriptionsByTopicResult"]["Subscriptions"]
|
||||
topic1_subscriptions = conn.get_all_subscriptions_by_topic(topic1_arn)[
|
||||
"ListSubscriptionsByTopicResponse"]["ListSubscriptionsByTopicResult"]["Subscriptions"]
|
||||
topic1_subscriptions.should.have.length_of(1)
|
||||
topic1_subscriptions[0]['Endpoint'].should.equal("http://example1.com/")
|
||||
|
||||
|
|
@ -63,25 +67,36 @@ def test_subscription_paging():
|
|||
topic2_arn = topics[1]['TopicArn']
|
||||
|
||||
for index in range(DEFAULT_PAGE_SIZE + int(DEFAULT_PAGE_SIZE / 3)):
|
||||
conn.subscribe(topic1_arn, 'email', 'email_' + str(index) + '@test.com')
|
||||
conn.subscribe(topic2_arn, 'email', 'email_' + str(index) + '@test.com')
|
||||
conn.subscribe(topic1_arn, 'email', 'email_' +
|
||||
str(index) + '@test.com')
|
||||
conn.subscribe(topic2_arn, 'email', 'email_' +
|
||||
str(index) + '@test.com')
|
||||
|
||||
all_subscriptions = conn.get_all_subscriptions()
|
||||
all_subscriptions["ListSubscriptionsResponse"]["ListSubscriptionsResult"]["Subscriptions"].should.have.length_of(DEFAULT_PAGE_SIZE)
|
||||
next_token = all_subscriptions["ListSubscriptionsResponse"]["ListSubscriptionsResult"]["NextToken"]
|
||||
all_subscriptions["ListSubscriptionsResponse"]["ListSubscriptionsResult"][
|
||||
"Subscriptions"].should.have.length_of(DEFAULT_PAGE_SIZE)
|
||||
next_token = all_subscriptions["ListSubscriptionsResponse"][
|
||||
"ListSubscriptionsResult"]["NextToken"]
|
||||
next_token.should.equal(DEFAULT_PAGE_SIZE)
|
||||
|
||||
all_subscriptions = conn.get_all_subscriptions(next_token=next_token * 2)
|
||||
all_subscriptions["ListSubscriptionsResponse"]["ListSubscriptionsResult"]["Subscriptions"].should.have.length_of(int(DEFAULT_PAGE_SIZE * 2 / 3))
|
||||
next_token = all_subscriptions["ListSubscriptionsResponse"]["ListSubscriptionsResult"]["NextToken"]
|
||||
all_subscriptions["ListSubscriptionsResponse"]["ListSubscriptionsResult"][
|
||||
"Subscriptions"].should.have.length_of(int(DEFAULT_PAGE_SIZE * 2 / 3))
|
||||
next_token = all_subscriptions["ListSubscriptionsResponse"][
|
||||
"ListSubscriptionsResult"]["NextToken"]
|
||||
next_token.should.equal(None)
|
||||
|
||||
topic1_subscriptions = conn.get_all_subscriptions_by_topic(topic1_arn)
|
||||
topic1_subscriptions["ListSubscriptionsByTopicResponse"]["ListSubscriptionsByTopicResult"]["Subscriptions"].should.have.length_of(DEFAULT_PAGE_SIZE)
|
||||
next_token = topic1_subscriptions["ListSubscriptionsByTopicResponse"]["ListSubscriptionsByTopicResult"]["NextToken"]
|
||||
topic1_subscriptions["ListSubscriptionsByTopicResponse"]["ListSubscriptionsByTopicResult"][
|
||||
"Subscriptions"].should.have.length_of(DEFAULT_PAGE_SIZE)
|
||||
next_token = topic1_subscriptions["ListSubscriptionsByTopicResponse"][
|
||||
"ListSubscriptionsByTopicResult"]["NextToken"]
|
||||
next_token.should.equal(DEFAULT_PAGE_SIZE)
|
||||
|
||||
topic1_subscriptions = conn.get_all_subscriptions_by_topic(topic1_arn, next_token=next_token)
|
||||
topic1_subscriptions["ListSubscriptionsByTopicResponse"]["ListSubscriptionsByTopicResult"]["Subscriptions"].should.have.length_of(int(DEFAULT_PAGE_SIZE / 3))
|
||||
next_token = topic1_subscriptions["ListSubscriptionsByTopicResponse"]["ListSubscriptionsByTopicResult"]["NextToken"]
|
||||
topic1_subscriptions = conn.get_all_subscriptions_by_topic(
|
||||
topic1_arn, next_token=next_token)
|
||||
topic1_subscriptions["ListSubscriptionsByTopicResponse"]["ListSubscriptionsByTopicResult"][
|
||||
"Subscriptions"].should.have.length_of(int(DEFAULT_PAGE_SIZE / 3))
|
||||
next_token = topic1_subscriptions["ListSubscriptionsByTopicResponse"][
|
||||
"ListSubscriptionsByTopicResult"]["NextToken"]
|
||||
next_token.should.equal(None)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ def test_getting_subscriptions_by_topic():
|
|||
Protocol="http",
|
||||
Endpoint="http://example2.com/")
|
||||
|
||||
topic1_subscriptions = conn.list_subscriptions_by_topic(TopicArn=topic1_arn)["Subscriptions"]
|
||||
topic1_subscriptions = conn.list_subscriptions_by_topic(TopicArn=topic1_arn)[
|
||||
"Subscriptions"]
|
||||
topic1_subscriptions.should.have.length_of(1)
|
||||
topic1_subscriptions[0]['Endpoint'].should.equal("http://example1.com/")
|
||||
|
||||
|
|
@ -77,14 +78,19 @@ def test_subscription_paging():
|
|||
next_token.should.equal(str(DEFAULT_PAGE_SIZE))
|
||||
|
||||
all_subscriptions = conn.list_subscriptions(NextToken=next_token)
|
||||
all_subscriptions["Subscriptions"].should.have.length_of(int(DEFAULT_PAGE_SIZE / 3))
|
||||
all_subscriptions["Subscriptions"].should.have.length_of(
|
||||
int(DEFAULT_PAGE_SIZE / 3))
|
||||
all_subscriptions.shouldnt.have("NextToken")
|
||||
|
||||
topic1_subscriptions = conn.list_subscriptions_by_topic(TopicArn=topic1_arn)
|
||||
topic1_subscriptions["Subscriptions"].should.have.length_of(DEFAULT_PAGE_SIZE)
|
||||
topic1_subscriptions = conn.list_subscriptions_by_topic(
|
||||
TopicArn=topic1_arn)
|
||||
topic1_subscriptions["Subscriptions"].should.have.length_of(
|
||||
DEFAULT_PAGE_SIZE)
|
||||
next_token = topic1_subscriptions["NextToken"]
|
||||
next_token.should.equal(str(DEFAULT_PAGE_SIZE))
|
||||
|
||||
topic1_subscriptions = conn.list_subscriptions_by_topic(TopicArn=topic1_arn, NextToken=next_token)
|
||||
topic1_subscriptions["Subscriptions"].should.have.length_of(int(DEFAULT_PAGE_SIZE / 3))
|
||||
topic1_subscriptions = conn.list_subscriptions_by_topic(
|
||||
TopicArn=topic1_arn, NextToken=next_token)
|
||||
topic1_subscriptions["Subscriptions"].should.have.length_of(
|
||||
int(DEFAULT_PAGE_SIZE / 3))
|
||||
topic1_subscriptions.shouldnt.have("NextToken")
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ def test_create_and_delete_topic():
|
|||
@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)
|
||||
conn.get_topic_attributes.when.called_with(
|
||||
"a-fake-arn").should.throw(BotoServerError)
|
||||
|
||||
|
||||
@mock_sns_deprecated
|
||||
|
|
@ -42,7 +43,9 @@ 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)
|
||||
list(conn.get_all_topics()["ListTopicsResponse"][
|
||||
"ListTopicsResult"]["Topics"]).should.have.length_of(1)
|
||||
|
||||
|
||||
@mock_sns_deprecated
|
||||
def test_topic_corresponds_to_region():
|
||||
|
|
@ -50,8 +53,11 @@ def test_topic_corresponds_to_region():
|
|||
conn = boto.sns.connect_to_region(region)
|
||||
conn.create_topic("some-topic")
|
||||
topics_json = conn.get_all_topics()
|
||||
topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0]['TopicArn']
|
||||
topic_arn.should.equal("arn:aws:sns:{0}:123456789012:some-topic".format(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_deprecated
|
||||
def test_topic_attributes():
|
||||
|
|
@ -59,9 +65,11 @@ def test_topic_attributes():
|
|||
conn.create_topic("some-topic")
|
||||
|
||||
topics_json = conn.get_all_topics()
|
||||
topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0]['TopicArn']
|
||||
topic_arn = topics_json["ListTopicsResponse"][
|
||||
"ListTopicsResult"]["Topics"][0]['TopicArn']
|
||||
|
||||
attributes = conn.get_topic_attributes(topic_arn)['GetTopicAttributesResponse']['GetTopicAttributesResult']['Attributes']
|
||||
attributes = conn.get_topic_attributes(topic_arn)['GetTopicAttributesResponse'][
|
||||
'GetTopicAttributesResult']['Attributes']
|
||||
attributes["TopicArn"].should.equal(
|
||||
"arn:aws:sns:{0}:123456789012:some-topic"
|
||||
.format(conn.region.name)
|
||||
|
|
@ -73,7 +81,8 @@ def test_topic_attributes():
|
|||
attributes["SubscriptionsConfirmed"].should.equal(0)
|
||||
attributes["SubscriptionsDeleted"].should.equal(0)
|
||||
attributes["DeliveryPolicy"].should.equal("")
|
||||
attributes["EffectiveDeliveryPolicy"].should.equal(DEFAULT_EFFECTIVE_DELIVERY_POLICY)
|
||||
attributes["EffectiveDeliveryPolicy"].should.equal(
|
||||
DEFAULT_EFFECTIVE_DELIVERY_POLICY)
|
||||
|
||||
# boto can't handle prefix-mandatory strings:
|
||||
# i.e. unicode on Python 2 -- u"foobar"
|
||||
|
|
@ -90,10 +99,13 @@ def test_topic_attributes():
|
|||
conn.set_topic_attributes(topic_arn, "DisplayName", displayname)
|
||||
conn.set_topic_attributes(topic_arn, "DeliveryPolicy", delivery)
|
||||
|
||||
attributes = conn.get_topic_attributes(topic_arn)['GetTopicAttributesResponse']['GetTopicAttributesResult']['Attributes']
|
||||
attributes = conn.get_topic_attributes(topic_arn)['GetTopicAttributesResponse'][
|
||||
'GetTopicAttributesResult']['Attributes']
|
||||
attributes["Policy"].should.equal("{'foo': 'bar'}")
|
||||
attributes["DisplayName"].should.equal("My display name")
|
||||
attributes["DeliveryPolicy"].should.equal("{'http': {'defaultHealthyRetryPolicy': {'numRetries': 5}}}")
|
||||
attributes["DeliveryPolicy"].should.equal(
|
||||
"{'http': {'defaultHealthyRetryPolicy': {'numRetries': 5}}}")
|
||||
|
||||
|
||||
@mock_sns_deprecated
|
||||
def test_topic_paging():
|
||||
|
|
@ -102,15 +114,19 @@ def test_topic_paging():
|
|||
conn.create_topic("some-topic_" + str(index))
|
||||
|
||||
topics_json = conn.get_all_topics()
|
||||
topics_list = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"]
|
||||
next_token = topics_json["ListTopicsResponse"]["ListTopicsResult"]["NextToken"]
|
||||
topics_list = topics_json["ListTopicsResponse"][
|
||||
"ListTopicsResult"]["Topics"]
|
||||
next_token = topics_json["ListTopicsResponse"][
|
||||
"ListTopicsResult"]["NextToken"]
|
||||
|
||||
len(topics_list).should.equal(DEFAULT_PAGE_SIZE)
|
||||
next_token.should.equal(DEFAULT_PAGE_SIZE)
|
||||
|
||||
topics_json = conn.get_all_topics(next_token=next_token)
|
||||
topics_list = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"]
|
||||
next_token = topics_json["ListTopicsResponse"]["ListTopicsResult"]["NextToken"]
|
||||
topics_list = topics_json["ListTopicsResponse"][
|
||||
"ListTopicsResult"]["Topics"]
|
||||
next_token = topics_json["ListTopicsResponse"][
|
||||
"ListTopicsResult"]["NextToken"]
|
||||
|
||||
topics_list.should.have.length_of(int(DEFAULT_PAGE_SIZE / 2))
|
||||
next_token.should.equal(None)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ def test_create_and_delete_topic():
|
|||
@mock_sns
|
||||
def test_get_missing_topic():
|
||||
conn = boto3.client("sns", region_name="us-east-1")
|
||||
conn.get_topic_attributes.when.called_with(TopicArn="a-fake-arn").should.throw(ClientError)
|
||||
conn.get_topic_attributes.when.called_with(
|
||||
TopicArn="a-fake-arn").should.throw(ClientError)
|
||||
|
||||
|
||||
@mock_sns
|
||||
|
|
@ -53,7 +54,8 @@ def test_topic_corresponds_to_region():
|
|||
conn.create_topic(Name="some-topic")
|
||||
topics_json = conn.list_topics()
|
||||
topic_arn = topics_json["Topics"][0]['TopicArn']
|
||||
topic_arn.should.equal("arn:aws:sns:{0}:123456789012:some-topic".format(region))
|
||||
topic_arn.should.equal(
|
||||
"arn:aws:sns:{0}:123456789012:some-topic".format(region))
|
||||
|
||||
|
||||
@mock_sns
|
||||
|
|
@ -76,7 +78,8 @@ def test_topic_attributes():
|
|||
attributes["SubscriptionsConfirmed"].should.equal('0')
|
||||
attributes["SubscriptionsDeleted"].should.equal('0')
|
||||
attributes["DeliveryPolicy"].should.equal("")
|
||||
attributes["EffectiveDeliveryPolicy"].should.equal(DEFAULT_EFFECTIVE_DELIVERY_POLICY)
|
||||
attributes["EffectiveDeliveryPolicy"].should.equal(
|
||||
DEFAULT_EFFECTIVE_DELIVERY_POLICY)
|
||||
|
||||
# boto can't handle prefix-mandatory strings:
|
||||
# i.e. unicode on Python 2 -- u"foobar"
|
||||
|
|
@ -84,11 +87,13 @@ def test_topic_attributes():
|
|||
if six.PY2:
|
||||
policy = json.dumps({b"foo": b"bar"})
|
||||
displayname = b"My display name"
|
||||
delivery = json.dumps({b"http": {b"defaultHealthyRetryPolicy": {b"numRetries": 5}}})
|
||||
delivery = json.dumps(
|
||||
{b"http": {b"defaultHealthyRetryPolicy": {b"numRetries": 5}}})
|
||||
else:
|
||||
policy = json.dumps({u"foo": u"bar"})
|
||||
displayname = u"My display name"
|
||||
delivery = json.dumps({u"http": {u"defaultHealthyRetryPolicy": {u"numRetries": 5}}})
|
||||
delivery = json.dumps(
|
||||
{u"http": {u"defaultHealthyRetryPolicy": {u"numRetries": 5}}})
|
||||
conn.set_topic_attributes(TopicArn=topic_arn,
|
||||
AttributeName="Policy",
|
||||
AttributeValue=policy)
|
||||
|
|
@ -102,7 +107,8 @@ def test_topic_attributes():
|
|||
attributes = conn.get_topic_attributes(TopicArn=topic_arn)['Attributes']
|
||||
attributes["Policy"].should.equal('{"foo": "bar"}')
|
||||
attributes["DisplayName"].should.equal("My display name")
|
||||
attributes["DeliveryPolicy"].should.equal('{"http": {"defaultHealthyRetryPolicy": {"numRetries": 5}}}')
|
||||
attributes["DeliveryPolicy"].should.equal(
|
||||
'{"http": {"defaultHealthyRetryPolicy": {"numRetries": 5}}}')
|
||||
|
||||
|
||||
@mock_sns
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue