<s> from unittest import TestCase <EOL> from nose . tools import eq_ <EOL> from six . moves import xrange <EOL> from pyelasticsearch import bulk_chunks <EOL> class BulkChunksTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> @ staticmethod <EOL> def str_xrange ( top ) : <EOL> return ( str ( x ) for x in xrange ( top ) ) <EOL> def test_under ( self ) : <EOL> """<STR_LIT>""" <EOL> actions = self . str_xrange ( <NUM_LIT:1> ) <EOL> chunks = bulk_chunks ( actions , docs_per_chunk = <NUM_LIT:2> ) <EOL> eq_ ( list ( chunks ) , [ [ '<STR_LIT:0>' ] ] ) <EOL> def test_over ( self ) : <EOL> """<STR_LIT>""" <EOL> actions = self . str_xrange ( <NUM_LIT:7> ) <EOL> chunks = bulk_chunks ( actions , docs_per_chunk = <NUM_LIT:3> ) <EOL> eq_ ( list ( chunks ) , [ [ '<STR_LIT:0>' , '<STR_LIT:1>' , '<STR_LIT:2>' ] , [ '<STR_LIT:3>' , '<STR_LIT:4>' , '<STR_LIT:5>' ] , [ '<STR_LIT>' ] ] ) <EOL> def test_on ( self ) : <EOL> """<STR_LIT>""" <EOL> actions = self . str_xrange ( <NUM_LIT:4> ) <EOL> chunks = bulk_chunks ( actions , docs_per_chunk = <NUM_LIT:2> ) <EOL> eq_ ( list ( chunks ) , [ [ '<STR_LIT:0>' , '<STR_LIT:1>' ] , [ '<STR_LIT:2>' , '<STR_LIT:3>' ] ] ) <EOL> def test_none ( self ) : <EOL> """<STR_LIT>""" <EOL> actions = self . str_xrange ( <NUM_LIT:0> ) <EOL> chunks = bulk_chunks ( actions , docs_per_chunk = <NUM_LIT:2> ) <EOL> eq_ ( list ( chunks ) , [ ] ) <EOL> def test_bytes ( self ) : <EOL> """<STR_LIT>""" <EOL> actions = [ '<STR_LIT:o>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> chunks = bulk_chunks ( actions , bytes_per_chunk = <NUM_LIT:5> ) <EOL> eq_ ( list ( chunks ) , [ [ '<STR_LIT:o>' , '<STR_LIT>' ] , [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ] ) <EOL> def test_bytes_first_too_big ( self ) : <EOL> """<STR_LIT>""" <EOL> actions = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> chunks = bulk_chunks ( actions , bytes_per_chunk = <NUM_LIT:6> ) <EOL> eq_ ( list ( chunks ) , [ [ '<STR_LIT>' ] , [ '<STR_LIT>' , '<STR_LIT>' ] ] ) </s>
