fix bug in Stream init (wrong number of shards)
This commit is contained in:
		
							parent
							
								
									5a20755565
								
							
						
					
					
						commit
						fa3fd729d1
					
				| @ -121,17 +121,11 @@ class Stream(BaseModel): | |||||||
|         self.shards = {} |         self.shards = {} | ||||||
|         self.tags = {} |         self.tags = {} | ||||||
| 
 | 
 | ||||||
|         if six.PY3: |         step = 2**128 // shard_count | ||||||
|             izip_longest = itertools.zip_longest |         for index, start, end in itertools.chain( | ||||||
|         else: |                                 map(lambda i: (i, i*step, (i+1) * step), range(shard_count - 1)), | ||||||
|             izip_longest = itertools.izip_longest |                                 [(shard_count - 1, (shard_count -1) * step, 2**128)]): | ||||||
| 
 | 
 | ||||||
|         for index, start, end in izip_longest(range(shard_count), |  | ||||||
|                                               range(0, 2**128, 2 ** |  | ||||||
|                                                     128 // shard_count), |  | ||||||
|                                               range(2**128 // shard_count, 2 ** |  | ||||||
|                                                     128, 2**128 // shard_count), |  | ||||||
|                                               fillvalue=2**128): |  | ||||||
|             shard = Shard(index, start, end) |             shard = Shard(index, start, end) | ||||||
|             self.shards[shard.shard_id] = shard |             self.shards[shard.shard_id] = shard | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ from moto import mock_kinesis, mock_kinesis_deprecated | |||||||
| def test_create_cluster(): | def test_create_cluster(): | ||||||
|     conn = boto.kinesis.connect_to_region("us-west-2") |     conn = boto.kinesis.connect_to_region("us-west-2") | ||||||
| 
 | 
 | ||||||
|     conn.create_stream("my_stream", 2) |     conn.create_stream("my_stream", 3) | ||||||
| 
 | 
 | ||||||
|     stream_response = conn.describe_stream("my_stream") |     stream_response = conn.describe_stream("my_stream") | ||||||
| 
 | 
 | ||||||
| @ -26,7 +26,7 @@ def test_create_cluster(): | |||||||
|     stream["StreamStatus"].should.equal("ACTIVE") |     stream["StreamStatus"].should.equal("ACTIVE") | ||||||
| 
 | 
 | ||||||
|     shards = stream['Shards'] |     shards = stream['Shards'] | ||||||
|     shards.should.have.length_of(2) |     shards.should.have.length_of(3) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @mock_kinesis_deprecated | @mock_kinesis_deprecated | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user