def test_content_type():
 transformer = hug.transform.content_type({'application/json': int, 'text/plain': str})
 class FakeRequest(object, ):
  content_type = 'application/json'
 request = FakeRequest()
 assert (transformer('1', request) == 1)
 request.content_type = 'text/plain'
 assert (transformer(2, request) == '2')
 request.content_type = 'undefined'
 (transformer({'data': 'value'}, request) == {'data': 'value'})

def test_content_type ( ) : transformer = hug . transform . content_type ( { 'application/json' : int , 'text/plain' : str } ) class FakeRequest ( object , ) : content_type = 'application/json' request = FakeRequest ( ) assert ( transformer ( '1' , request ) == 1 ) request . content_type = 'text/plain' assert ( transformer ( 2 , request ) == '2' ) request . content_type = 'undefined' ( transformer ( { 'data' : 'value' } , request ) == { 'data' : 'value' } )
test to ensure the transformer used can change based on the provided content-type .