Beispiel #1
0
 def test_regex_path(self):
     # set up
     v = lambda: None
     self.patches.patch('metaweb.views._regex_pathes', {re.compile('^/users/(?P<id>.*?)$'): v})
     
     # test
     path = views.match('/users/111')
     self.assertEqual('/users/111', path)
     self.assertEqual(v, path.view)
     self.assertEqual({'id': '111'}, path.args)
Beispiel #2
0
 def test_absolute_path(self):
     # set up
     v = lambda: None
     self.patches.patch('metaweb.views._abs_pathes', {'/users/': v})
     
     # test
     path = views.match('/users/')
     self.assertEqual('/users/', path)
     self.assertEqual(v, path.view)
     self.assertEqual({}, path.args)
Beispiel #3
0
def _match_view(path):
    path = views.match(path)
    if path is None:
        raise NotFoundResponse()
    return path
Beispiel #4
0
 def test_not_found(self):
     path = views.match('/users/create')
     self.assertIsNone(path)