~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/vostok/browser/tests/test_navigation.py

  • Committer: Guilherme Salgado
  • Date: 2010-08-13 15:33:40 UTC
  • mto: This revision was merged to the branch mainline in revision 11355.
  • Revision ID: salgado@canonical.com-20100813153340-g79zo2qpzyjkoi2i
merge two tests and fix the navigation declaration for IDistribution on the vostok layer

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
__metaclass__ = type
7
7
 
8
8
from zope.publisher.interfaces import NotFound
 
9
from zope.security.proxy import removeSecurityProxy
9
10
 
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
12
13
 
13
14
from lp.testing import TestCaseWithFactory
14
15
from lp.testing.publication import test_traverse
15
16
 
16
17
 
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
19
 
# yet.
 
18
class TestRootNavigation(TestCaseWithFactory):
 
19
 
 
20
    layer = DatabaseFunctionalLayer
 
21
 
 
22
    def test_traverse_to_distributions(self):
 
23
        # We can traverse to a distribution by name from the vostok
 
24
        # root.
 
25
        distro = self.factory.makeDistribution()
 
26
        obj, view, request = test_traverse('http://vostok.dev/' + distro.name)
 
27
        self.assertEqual(distro, obj)
 
28
 
 
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)
 
38
 
 
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
 
42
        self.assertRaises(
 
43
            NotFound, test_traverse, 'http://vostok.dev/' + path)
 
44
 
 
45
 
20
46
class TestDistributionNavigation(TestCaseWithFactory):
21
47
 
22
48
    layer = DatabaseFunctionalLayer