1
# Copyright 2009 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Useful helper functions used for testing menus."""
8
from canonical.launchpad.webapp.publisher import canonical_url
11
def check_menu_links(menu):
12
context = menu.context
13
for link in menu.iterlinks():
14
if link.target.startswith(('/', 'http://')):
15
# The context is not the context of this target.
17
if '?' in link.target:
18
view_name, _args = link.target.split('?')
20
view_name = link.target
24
canonical_url(context, view_name=view_name, rootsite=link.site)
26
return 'Bad link %s: %s' % (link.name, canonical_url(context))