Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added fix and passing integration tests for kinesis put_records method. #413

Merged
merged 3 commits into from
Jan 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions botocore/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,15 @@ def _serialize_type_map(self, serialized, value, shape, key):
for sub_key, sub_value in value.items():
self._serialize(map_obj, sub_value, shape.value, sub_key)

def _serialize_type_list(self, serialized, value, shape, key):
list_obj = []
serialized[key] = list_obj
for list_item in value:
shell = {}
self._serialize(shell, list_item, shape.member, "s")
list_obj.append(shell["s"])
pass

def _default_serialize(self, serialized, value, shape, key):
serialized[key] = value

Expand Down
62 changes: 62 additions & 0 deletions tests/integration/test_kinesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,68 @@ def test_can_put_stream_blob(self):
self.assertTrue(len(records['Records']) > 0)
self.assertEqual(records['Records'][0]['Data'], b'foobar')

def test_can_put_records_single_blob(self):
self.client.create_stream(StreamName=self.stream_name,
ShardCount=1)
waiter = self.client.get_waiter('stream_exists')
waiter.wait(StreamName=self.stream_name)
self.addCleanup(self.client.delete_stream,
StreamName=self.stream_name)

self.client.put_records(
StreamName=self.stream_name,
Records=[{
'Data': 'foobar',
'PartitionKey': 'foo'
}]
)
# Give it a few seconds for the record to get into the stream.
time.sleep(10)

stream = self.client.describe_stream(StreamName=self.stream_name)
shard = stream['StreamDescription']['Shards'][0]
shard_iterator = self.client.get_shard_iterator(
StreamName=self.stream_name, ShardId=shard['ShardId'],
ShardIteratorType='TRIM_HORIZON')

records = self.client.get_records(
ShardIterator=shard_iterator['ShardIterator'])
self.assertTrue(len(records['Records']) > 0)
self.assertEqual(records['Records'][0]['Data'], b'foobar')

def test_can_put_records_multiple_blob(self):
self.client.create_stream(StreamName=self.stream_name,
ShardCount=1)
waiter = self.client.get_waiter('stream_exists')
waiter.wait(StreamName=self.stream_name)
self.addCleanup(self.client.delete_stream,
StreamName=self.stream_name)

self.client.put_records(
StreamName=self.stream_name,
Records=[{
'Data': 'foobar',
'PartitionKey': 'foo'
},{
'Data': 'barfoo',
'PartitionKey': 'foo'
}]
)
# Give it a few seconds for the record to get into the stream.
time.sleep(10)

stream = self.client.describe_stream(StreamName=self.stream_name)
shard = stream['StreamDescription']['Shards'][0]
shard_iterator = self.client.get_shard_iterator(
StreamName=self.stream_name, ShardId=shard['ShardId'],
ShardIteratorType='TRIM_HORIZON')

records = self.client.get_records(
ShardIterator=shard_iterator['ShardIterator'])
self.assertTrue(len(records['Records']) == 2)
#verify that both made it through
record_data = [r['Data'] for r in records['Records']]
self.assertItemsEqual(['foobar', 'barfoo'], record_data)

if __name__ == '__main__':
unittest.main()