<s> """<STR_LIT>""" <EOL> import json <EOL> from cloudroast . objectstorage . fixtures import ObjectStorageFixture <EOL> CONTENT_TYPE_TEXT = '<STR_LIT>' <EOL> CONTAINER_NAME = '<STR_LIT>' <EOL> class ListLimitTest ( ObjectStorageFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( ListLimitTest , cls ) . setUpClass ( ) <EOL> cls . container_name = CONTAINER_NAME <EOL> cls . client . create_container ( cls . container_name ) <EOL> object_data = '<STR_LIT>' <EOL> content_length = str ( len ( object_data ) ) <EOL> headers = { '<STR_LIT>' : content_length , <EOL> '<STR_LIT:Content-Type>' : CONTENT_TYPE_TEXT } <EOL> cls . obj_names = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> for obj_name in cls . obj_names : <EOL> cls . client . create_object ( <EOL> cls . container_name , <EOL> obj_name , <EOL> headers = headers , <EOL> data = object_data ) <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> super ( ListLimitTest , cls ) . setUpClass ( ) <EOL> cls . behaviors . force_delete_containers ( [ cls . container_name ] ) <EOL> def test_list_limit ( self ) : <EOL> params = { "<STR_LIT>" : "<STR_LIT:2>" , "<STR_LIT>" : "<STR_LIT>" } <EOL> response = self . client . list_objects ( self . container_name , params = params ) <EOL> content = None <EOL> try : <EOL> content = json . loads ( response . content ) <EOL> except ValueError , error : <EOL> self . fixture_log . exception ( error ) <EOL> members = [ ] <EOL> for member in content : <EOL> if '<STR_LIT:name>' in member . keys ( ) : <EOL> members . append ( member [ '<STR_LIT:name>' ] ) <EOL> else : <EOL> continue <EOL> self . assertTrue ( response . ok ) <EOL> expected = <NUM_LIT:2> <EOL> recieved = len ( members ) <EOL> self . assertEqual ( <EOL> expected , <EOL> recieved , <EOL> msg = "<STR_LIT>" . format ( <EOL> expected , <EOL> recieved ) ) <EOL> self . assertIn ( "<STR_LIT>" , members , msg = "<STR_LIT>" ) <EOL> self . assertIn ( "<STR_LIT>" , members , msg = "<STR_LIT>" ) <EOL> def test_list_limit_zero ( self ) : <EOL> params = { "<STR_LIT>" : "<STR_LIT:0>" , "<STR_LIT>" : "<STR_LIT>" } <EOL> response = self . client . list_objects ( self . container_name , params = params ) <EOL> content = json . loads ( response . content ) <EOL> members = [ ] <EOL> for member in content : <EOL> if '<STR_LIT:name>' in member . keys ( ) : <EOL> members . append ( member [ '<STR_LIT:name>' ] ) <EOL> else : <EOL> continue <EOL> self . assertTrue ( response . ok ) <EOL> expected = <NUM_LIT:0> <EOL> recieved = len ( members ) <EOL> self . assertEqual ( <EOL> expected , <EOL> recieved , <EOL> msg = "<STR_LIT>" . format ( <EOL> expected , <EOL> recieved ) ) </s>
