This commit is contained in:
Steve Pulec 2017-02-23 21:37:43 -05:00
commit f37bad0e00
260 changed files with 6363 additions and 3766 deletions

View file

@ -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)