def test_suffix():
 transformer = hug.transform.suffix({'.js': int, '.txt': str})
 class FakeRequest(object, ):
  path = 'hey.js'
 request = FakeRequest()
 assert (transformer('1', request) == 1)
 request.path = 'hey.txt'
 assert (transformer(2, request) == '2')
 request.path = 'hey.undefined'
 (transformer({'data': 'value'}, request) == {'data': 'value'})

def test_suffix ( ) : transformer = hug . transform . suffix ( { '.js' : int , '.txt' : str } ) class FakeRequest ( object , ) : path = 'hey.js' request = FakeRequest ( ) assert ( transformer ( '1' , request ) == 1 ) request . path = 'hey.txt' assert ( transformer ( 2 , request ) == '2' ) request . path = 'hey.undefined' ( transformer ( { 'data' : 'value' } , request ) == { 'data' : 'value' } )
ensure that its possible to route the output type format by the suffix of the requested url .