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)
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)
def _match_view(path): path = views.match(path) if path is None: raise NotFoundResponse() return path
def test_not_found(self): path = views.match('/users/create') self.assertIsNone(path)