<s> from __future__ import unicode_literals <EOL> from nose . tools import eq_ <EOL> from werkzeug . test import Client <EOL> from werkzeug . wrappers import BaseResponse <EOL> from clastic import Application , render_basic <EOL> from clastic . route import GET , POST , PUT , DELETE <EOL> def test_http_method_routes ( ) : <EOL> ep = lambda _route : repr ( _route . methods ) <EOL> routes = [ GET ( '<STR_LIT>' , ep , render_basic ) , <EOL> POST ( '<STR_LIT>' , ep , render_basic ) , <EOL> PUT ( '<STR_LIT>' , ep , render_basic ) , <EOL> DELETE ( '<STR_LIT>' , ep , render_basic ) ] <EOL> app = Application ( routes ) <EOL> client = Client ( app , BaseResponse ) <EOL> methods = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> status_map = { } <EOL> for correct_method in methods : <EOL> for attempted_method in methods : <EOL> req_func = getattr ( client , attempted_method ) <EOL> resp = req_func ( '<STR_LIT:/>' + correct_method ) <EOL> status_code = resp . status_code <EOL> try : <EOL> status_map [ status_code ] += <NUM_LIT:1> <EOL> except KeyError : <EOL> status_map [ status_code ] = <NUM_LIT:1> <EOL> if status_code == <NUM_LIT:200> : <EOL> resp_data = resp . data <EOL> route_methods = eval ( resp_data ) - set ( [ '<STR_LIT>' ] ) <EOL> yield eq_ , set ( [ correct_method . upper ( ) ] ) , route_methods <EOL> yield eq_ , status_map [ <NUM_LIT:200> ] , len ( routes ) <EOL> yield eq_ , status_map . get ( <NUM_LIT> ) , len ( routes ) * ( len ( methods ) - <NUM_LIT:1> ) <EOL> return </s>
