<s> """<STR_LIT>""" <EOL> from cafe . drivers . unittest . decorators import ( <EOL> DataDrivenFixture , data_driven_test ) <EOL> from cloudcafe . objectstorage . objectstorage_api . common . constants import Constants <EOL> from cloudroast . objectstorage . fixtures import ObjectStorageFixture <EOL> from cloudroast . objectstorage . generators import ObjectDatasetList <EOL> CONTAINER_NAME = '<STR_LIT>' <EOL> CONTENT_MSG = '<STR_LIT>' <EOL> CONTENT_TYPE_MSG = '<STR_LIT>' <EOL> MULTIPART = "<STR_LIT>" <EOL> @ DataDrivenFixture <EOL> class ObjectRangeRequestTest ( ObjectStorageFixture ) : <EOL> def setUp ( self ) : <EOL> super ( ObjectRangeRequestTest , self ) . setUp ( ) <EOL> self . container_name = self . create_temp_container ( <EOL> descriptor = CONTAINER_NAME ) <EOL> self . object_name = Constants . VALID_OBJECT_NAME <EOL> def get_boundary ( self , content_type_header ) : <EOL> """<STR_LIT>""" <EOL> boundary = '<STR_LIT>' <EOL> header_tokens = content_type_header . split ( "<STR_LIT>" ) <EOL> try : <EOL> boundary = header_tokens [ <NUM_LIT:1> ] <EOL> except IndexError , error : <EOL> self . fail ( <EOL> msg = '<STR_LIT>' <EOL> '<STR_LIT>' . format ( <EOL> str ( content_type_header ) , <EOL> error ) ) <EOL> return boundary <EOL> def parse_msg ( self , content , boundary ) : <EOL> """<STR_LIT>""" <EOL> multipart_content = { } <EOL> try : <EOL> split_body = content . split ( "<STR_LIT>" . format ( boundary ) ) <EOL> except AttributeError , error : <EOL> self . fail ( "<STR_LIT>" <EOL> "<STR_LIT>" . format ( error ) ) <EOL> i = <NUM_LIT:1> <EOL> end = len ( split_body ) - <NUM_LIT:1> <EOL> try : <EOL> while ( i < end ) : <EOL> multipart_content [ '<STR_LIT>' . format ( i ) ] = split_body [ i ] . split ( '<STR_LIT>' ) [ <NUM_LIT:1> ] . strip ( '<STR_LIT:\r\n>' ) <EOL> i += <NUM_LIT:1> <EOL> except AttributeError , error : <EOL> self . error ( "<STR_LIT>" . format ( error ) ) <EOL> return multipart_content <EOL> @ data_driven_test ( ObjectDatasetList ( ) ) <EOL> def ddtest_basic_object_range_request ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> obj_data = "<STR_LIT>" <EOL> headers = { '<STR_LIT>' : str ( len ( obj_data ) ) } <EOL> self . behaviors . create_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers , <EOL> data = obj_data ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> self . assertEqual ( response . content , "<STR_LIT>" , <EOL> msg = CONTENT_MSG . format ( "<STR_LIT>" , str ( response . content ) ) ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> self . assertEqual ( response . content , "<STR_LIT>" , <EOL> msg = CONTENT_MSG . format ( "<STR_LIT>" , str ( response . content ) ) ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> self . assertEqual ( response . content , "<STR_LIT:_>" , <EOL> msg = CONTENT_MSG . format ( "<STR_LIT:_>" , str ( response . content ) ) ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> self . assertEqual ( <EOL> response . content , <EOL> "<STR_LIT>" , <EOL> msg = CONTENT_MSG . format ( <EOL> "<STR_LIT>" , <EOL> str ( response . content ) ) ) <EOL> @ data_driven_test ( ObjectDatasetList ( ) ) <EOL> def ddtest_multi_part_range_request ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> obj_data = "<STR_LIT>" <EOL> headers = { '<STR_LIT>' : str ( len ( obj_data ) ) } <EOL> self . behaviors . create_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers , <EOL> data = obj_data ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> content_type = response . headers . get ( '<STR_LIT>' ) <EOL> self . assertTrue ( str ( content_type ) . startswith ( MULTIPART ) ) <EOL> boundary = self . get_boundary ( content_type ) <EOL> self . assertNotEqual ( boundary , '<STR_LIT>' ) <EOL> parsed_content = self . parse_msg ( response . content , boundary ) <EOL> self . assertEqual ( "<STR_LIT>" , parsed_content . get ( '<STR_LIT>' ) , <EOL> msg = CONTENT_MSG . format ( "<STR_LIT>" , str ( response . content ) ) ) <EOL> self . assertEqual ( "<STR_LIT>" , parsed_content . get ( '<STR_LIT>' ) , <EOL> msg = CONTENT_MSG . format ( "<STR_LIT>" , str ( response . content ) ) ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> content_type = response . headers . get ( '<STR_LIT>' ) <EOL> self . assertTrue ( str ( content_type ) . startswith ( MULTIPART ) ) <EOL> boundary = self . get_boundary ( content_type ) <EOL> self . assertNotEqual ( boundary , '<STR_LIT>' ) <EOL> parsed_content = self . parse_msg ( response . content , boundary ) <EOL> self . assertEqual ( "<STR_LIT>" , parsed_content . get ( '<STR_LIT>' ) , <EOL> msg = CONTENT_MSG . format ( "<STR_LIT>" , str ( response . content ) ) ) <EOL> self . assertEqual ( "<STR_LIT>" , parsed_content . get ( '<STR_LIT>' ) , <EOL> msg = CONTENT_MSG . format ( "<STR_LIT>" , str ( response . content ) ) ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> content_type = response . headers . get ( '<STR_LIT>' ) <EOL> self . assertTrue ( str ( content_type ) . startswith ( MULTIPART ) ) <EOL> boundary = self . get_boundary ( content_type ) <EOL> self . assertNotEqual ( boundary , '<STR_LIT>' ) <EOL> parsed_content = self . parse_msg ( response . content , boundary ) <EOL> self . assertEqual ( <EOL> "<STR_LIT>" , <EOL> parsed_content . get ( '<STR_LIT>' ) , <EOL> msg = CONTENT_MSG . format ( "<STR_LIT>" , str ( response . content ) ) ) <EOL> self . assertEqual ( "<STR_LIT>" , parsed_content . get ( '<STR_LIT>' ) , <EOL> msg = CONTENT_MSG . format ( "<STR_LIT>" , str ( response . content ) ) ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> content_type = response . headers . get ( '<STR_LIT>' ) <EOL> self . assertTrue ( str ( content_type ) . startswith ( MULTIPART ) ) <EOL> boundary = self . get_boundary ( content_type ) <EOL> self . assertNotEqual ( boundary , '<STR_LIT>' ) <EOL> parsed_content = self . parse_msg ( response . content , boundary ) <EOL> self . assertEqual ( <EOL> "<STR_LIT>" , <EOL> parsed_content . get ( '<STR_LIT>' ) , <EOL> msg = CONTENT_MSG . format ( "<STR_LIT>" , str ( response . content ) ) ) <EOL> self . assertEqual ( "<STR_LIT>" , parsed_content . get ( '<STR_LIT>' ) , <EOL> msg = CONTENT_MSG . format ( "<STR_LIT>" , str ( response . content ) ) ) <EOL> self . assertEqual ( "<STR_LIT>" , parsed_content . get ( '<STR_LIT>' ) , <EOL> msg = CONTENT_MSG . format ( "<STR_LIT>" , str ( response . content ) ) ) <EOL> @ data_driven_test ( ObjectDatasetList ( ) ) <EOL> def ddtest_range_request_with_bad_ranges ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> obj_data = "<STR_LIT>" <EOL> headers = { '<STR_LIT>' : str ( len ( obj_data ) ) } <EOL> self . behaviors . create_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers , <EOL> data = obj_data ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> self . assertEqual ( <EOL> obj_data , <EOL> response . content , <EOL> msg = CONTENT_MSG . format ( <EOL> obj_data , <EOL> str ( response . content ) ) ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> self . assertEqual ( <EOL> obj_data , <EOL> response . content , <EOL> msg = CONTENT_MSG . format ( <EOL> obj_data , <EOL> str ( response . content ) ) ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> self . assertEqual ( <EOL> obj_data , <EOL> response . content , <EOL> msg = CONTENT_MSG . format ( <EOL> obj_data , <EOL> str ( response . content ) ) ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> self . assertEqual ( <EOL> obj_data , <EOL> response . content , <EOL> msg = CONTENT_MSG . format ( <EOL> obj_data , <EOL> str ( response . content ) ) ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> self . assertEqual ( <EOL> "<STR_LIT>" , <EOL> response . content , <EOL> msg = CONTENT_MSG . format ( <EOL> "<STR_LIT>" , <EOL> str ( response . content ) ) ) <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' } <EOL> response = self . client . get_object ( <EOL> self . container_name , <EOL> self . object_name , <EOL> headers = headers ) <EOL> self . assertEqual ( <EOL> obj_data , <EOL> response . content , <EOL> msg = CONTENT_MSG . format ( <EOL> obj_data , <EOL> str ( response . content ) ) ) </s>
