<s> import unittest <EOL> import unittest . mock <EOL> from vase . routing import ( <EOL> RequestSpec , <EOL> pattern_to_regex , <EOL> PatternRequestMatcher , <EOL> ) <EOL> class RequestSpecTests ( unittest . TestCase ) : <EOL> def test_request_spec ( self ) : <EOL> spec = RequestSpec ( "<STR_LIT:/>" ) <EOL> self . assertEqual ( spec . pattern , "<STR_LIT:/>" ) <EOL> self . assertEqual ( spec . methods , ( "<STR_LIT:*>" , ) ) <EOL> self . assertEqual ( str ( spec ) , "<STR_LIT>" ) <EOL> class PatternToRequestTests ( unittest . TestCase ) : <EOL> def test_basic ( self ) : <EOL> result = pattern_to_regex ( "<STR_LIT>" ) <EOL> self . assertEqual ( result . pattern , "<STR_LIT>" ) <EOL> result = pattern_to_regex ( "<STR_LIT>" ) <EOL> self . assertEqual ( result . pattern , '<STR_LIT>' ) <EOL> class PatternRequestMatcherTests ( unittest . TestCase ) : <EOL> def test ( self ) : <EOL> req = RequestSpec ( pattern = "<STR_LIT>" ) <EOL> matcher = PatternRequestMatcher ( req ) <EOL> request = unittest . mock . Mock ( ) <EOL> request . path = "<STR_LIT>" <EOL> self . assertEqual ( matcher . match ( request ) , { <EOL> '<STR_LIT:foo>' : '<STR_LIT:bar>' , <EOL> '<STR_LIT:bar>' : '<STR_LIT>' <EOL> } ) </s>
