<s> from six import iteritems <EOL> from django_downloadview . apache . response import XSendfileResponse <EOL> class XSendfileValidator ( object ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self , test_case , response , ** assertions ) : <EOL> """<STR_LIT>""" <EOL> self . assert_x_sendfile_response ( test_case , response ) <EOL> for key , value in iteritems ( assertions ) : <EOL> assert_func = getattr ( self , '<STR_LIT>' % key ) <EOL> assert_func ( test_case , response , value ) <EOL> def assert_x_sendfile_response ( self , test_case , response ) : <EOL> test_case . assertTrue ( isinstance ( response , XSendfileResponse ) ) <EOL> def assert_basename ( self , test_case , response , value ) : <EOL> test_case . assertEqual ( response . basename , value ) <EOL> def assert_content_type ( self , test_case , response , value ) : <EOL> test_case . assertEqual ( response [ '<STR_LIT:Content-Type>' ] , value ) <EOL> def assert_file_path ( self , test_case , response , value ) : <EOL> test_case . assertEqual ( response [ '<STR_LIT>' ] , value ) <EOL> def assert_attachment ( self , test_case , response , value ) : <EOL> header = '<STR_LIT>' <EOL> if value : <EOL> test_case . assertTrue ( response [ header ] . startswith ( '<STR_LIT>' ) ) <EOL> else : <EOL> test_case . assertFalse ( header in response ) <EOL> def assert_x_sendfile ( test_case , response , ** assertions ) : <EOL> """<STR_LIT>""" <EOL> validator = XSendfileValidator ( ) <EOL> return validator ( test_case , response , ** assertions ) </s>
