add implemented kinesis method describe_stream_summary (#2023)

This commit is contained in:
Alexey Firsov 2019-05-21 02:02:36 +03:00 committed by Terry Cain
commit f13e4e41cd
4 changed files with 59 additions and 15 deletions

View file

@ -1,12 +1,13 @@
from __future__ import unicode_literals
import boto.kinesis
from boto.kinesis.exceptions import ResourceNotFoundException, InvalidArgumentException
import boto3
import sure # noqa
import datetime
import time
import boto.kinesis
import boto3
from boto.kinesis.exceptions import ResourceNotFoundException, \
InvalidArgumentException
from moto import mock_kinesis, mock_kinesis_deprecated
@ -73,6 +74,23 @@ def test_list_many_streams():
has_more_streams.should.equal(False)
@mock_kinesis
def test_describe_stream_summary():
conn = boto3.client('kinesis', region_name="us-west-2")
stream_name = 'my_stream_summary'
shard_count = 5
conn.create_stream(StreamName=stream_name, ShardCount=shard_count)
resp = conn.describe_stream_summary(StreamName=stream_name)
stream = resp["StreamDescriptionSummary"]
stream["StreamName"].should.equal(stream_name)
stream["OpenShardCount"].should.equal(shard_count)
stream["StreamARN"].should.equal(
"arn:aws:kinesis:us-west-2:123456789012:{}".format(stream_name))
stream["StreamStatus"].should.equal("ACTIVE")
@mock_kinesis_deprecated
def test_basic_shard_iterator():
conn = boto.kinesis.connect_to_region("us-west-2")
@ -100,7 +118,8 @@ def test_get_invalid_shard_iterator():
conn.create_stream(stream_name, 1)
conn.get_shard_iterator.when.called_with(
stream_name, "123", 'TRIM_HORIZON').should.throw(ResourceNotFoundException)
stream_name, "123", 'TRIM_HORIZON').should.throw(
ResourceNotFoundException)
@mock_kinesis_deprecated
@ -354,8 +373,8 @@ def test_get_records_timestamp_filtering():
timestamp = datetime.datetime.utcnow()
conn.put_record(StreamName=stream_name,
Data='1',
PartitionKey='1')
Data='1',
PartitionKey='1')
response = conn.describe_stream(StreamName=stream_name)
shard_id = response['StreamDescription']['Shards'][0]['ShardId']
@ -368,7 +387,7 @@ def test_get_records_timestamp_filtering():
response = conn.get_records(ShardIterator=shard_iterator)
response['Records'].should.have.length_of(1)
response['Records'][0]['PartitionKey'].should.equal('1')
response['Records'][0]['ApproximateArrivalTimestamp'].should.be.\
response['Records'][0]['ApproximateArrivalTimestamp'].should.be. \
greater_than(timestamp)
response['MillisBehindLatest'].should.equal(0)
@ -461,7 +480,8 @@ def test_invalid_shard_iterator_type():
response = conn.describe_stream(stream_name)
shard_id = response['StreamDescription']['Shards'][0]['ShardId']
response = conn.get_shard_iterator.when.called_with(
stream_name, shard_id, 'invalid-type').should.throw(InvalidArgumentException)
stream_name, shard_id, 'invalid-type').should.throw(
InvalidArgumentException)
@mock_kinesis_deprecated
@ -549,7 +569,8 @@ def test_split_shard():
shard_range = shards[0]['HashKeyRange']
new_starting_hash = (
int(shard_range['EndingHashKey']) + int(shard_range['StartingHashKey'])) // 2
int(shard_range['EndingHashKey']) + int(
shard_range['StartingHashKey'])) // 2
conn.split_shard("my_stream", shards[0]['ShardId'], str(new_starting_hash))
stream_response = conn.describe_stream(stream_name)
@ -562,7 +583,8 @@ def test_split_shard():
shard_range = shards[2]['HashKeyRange']
new_starting_hash = (
int(shard_range['EndingHashKey']) + int(shard_range['StartingHashKey'])) // 2
int(shard_range['EndingHashKey']) + int(
shard_range['StartingHashKey'])) // 2
conn.split_shard("my_stream", shards[2]['ShardId'], str(new_starting_hash))
stream_response = conn.describe_stream(stream_name)
@ -592,7 +614,8 @@ def test_merge_shards():
shards.should.have.length_of(4)
conn.merge_shards.when.called_with(
stream_name, 'shardId-000000000000', 'shardId-000000000002').should.throw(InvalidArgumentException)
stream_name, 'shardId-000000000000',
'shardId-000000000002').should.throw(InvalidArgumentException)
stream_response = conn.describe_stream(stream_name)