8
8
from zope.publisher.interfaces import NotFound
9
from zope.security.proxy import removeSecurityProxy
10
from canonical.launchpad.webapp import canonical_url
11
from canonical.launchpad.webapp import canonical_url, urlparse
11
12
from canonical.testing.layers import DatabaseFunctionalLayer
13
14
from lp.testing import TestCaseWithFactory
14
15
from lp.testing.publication import test_traverse
17
# XXX: Should move the contents of lp/vostok/tests/test_navigation.py in here
18
# before merging. Haven't done that yet because that file is not in trunk
18
class TestRootNavigation(TestCaseWithFactory):
20
layer = DatabaseFunctionalLayer
22
def test_traverse_to_distributions(self):
23
# We can traverse to a distribution by name from the vostok
25
distro = self.factory.makeDistribution()
26
obj, view, request = test_traverse('http://vostok.dev/' + distro.name)
27
self.assertEqual(distro, obj)
29
def test_traverse_to_distribution_aliases(self):
30
# When we traverse to a distribution using one of its aliases, we're
31
# redirected to the distribution's page on the vostok vhost.
32
distro = self.factory.makeDistribution(aliases=['f00'])
33
obj, view, request = test_traverse('http://vostok.dev/f00')
34
naked_view = removeSecurityProxy(view)
35
parse_result = urlparse(naked_view.target)
36
self.assertEqual('vostok.dev', parse_result.netloc)
37
self.assertEqual('/' + distro.name, parse_result.path)
39
def test_can_not_traverse_to_projects(self):
40
# We cannot traverse to a project from the vostok root.
41
path = self.factory.makeProject().name
43
NotFound, test_traverse, 'http://vostok.dev/' + path)
20
46
class TestDistributionNavigation(TestCaseWithFactory):
22
48
layer = DatabaseFunctionalLayer