@@ -18,6 +18,7 @@ def test_handle_existing_route_only(self):
18
18
coroutine = router .handle_route (None , stream )
19
19
run (coroutine )
20
20
21
+ # todo: this test has some problem
21
22
def test_get_existing_route (self ):
22
23
router = Router (None , None )
23
24
stream = Stream (1 , {':path' : 'x' , ':method' : 'GET' })
@@ -40,12 +41,15 @@ async def f(http, stream):
40
41
coroutine = router .handle_route (None , stream )
41
42
run (coroutine )
42
43
43
- def test_parameterized_route (self ):
44
- router = Router (None , None )
45
- the_route = 'user/{user}'
46
- router ._route ('GET' , the_route , None )
47
- matched , parameters = router .match ('/user/abc' ) # todo: to be implemented
48
- self .assertEqual (the_route , matched )
49
- self .assertEqual (parameters ['user' ], 'abc' )
44
+ def test_match (self ):
45
+ # match true
46
+ matched , parameters = Router ._match ('user/{userId}/name/{name}' , 'user/123/name/John' )
47
+ self .assertTrue (matched )
48
+ self .assertEqual (parameters ['userId' ], '123' )
49
+ self .assertEqual (parameters ['name' ], 'John' )
50
+
51
+ # match false
52
+ matched , parameters = Router ._match ('user/{userId}/name/{name}' , 'user/123/nam/John' )
53
+ self .assertFalse (matched )
50
54
51
55
# will want to test with unicode
0 commit comments