def test_participation_restored(self):
     # test_traverse restores the interaction (and hence
     # participation) that was present before it was called.
     request = LaunchpadTestRequest()
     login(ANONYMOUS, request)
     product = self.factory.makeProduct()
     test_traverse('https://launchpad.dev/' + product.name)
     self.assertIs(request, get_current_browser_request())
 def test_webservice_traverse(self):
     login(ANONYMOUS)
     product = self.factory.makeProduct()
     context, view, request = test_traverse(
         'http://api.launchpad.dev/devel/' + product.name)
     self.assertEqual(product, context)
     self.assertIsInstance(view, EntryResource)
Exemplo n.º 3
0
 def getBreadcrumbsForUrl(self, url):
     obj, view, request = test_traverse(url)
     # Sometimes test_traverse returns the __call__, while the template
     # always has access to the instance.
     view = getattr(removeSecurityProxy(view), 'im_self', view)
     hier = create_initialized_view(view, '+hierarchy', request=request)
     return hier.items
 def test_latestbuild_unknown_arch(self):
     # If there is no build for the requested architecture, +latestbuild
     # redirects to the context DSPR.
     dspr_url, _ = self.setUpLatestBuildTests()
     obj, view, _ = test_traverse("%s/+latestbuild/unknown" % dspr_url)
     self.assertEqual(dspr_url, canonical_url(obj))
     self.assertEqual(303, removeSecurityProxy(view).status)
Exemplo n.º 5
0
 def test_traverse_stores_the_path(self):
     login(ANONYMOUS)
     object, view, request = test_traverse(
         'http://launchpad.dev/+yuitest/'
         'lib/lp/testing/tests/test_yuixhr_fixture.js')
     self.assertEquals('lib/lp/testing/tests/test_yuixhr_fixture.js',
                       removeSecurityProxy(view).traversed_path)
Exemplo n.º 6
0
 def test_self_url_traversal(self):
     # Just /~/ expands to the current user.  (Bug 785800).
     person = self.factory.makePerson()
     login_person(person)
     obj, view, req = test_traverse('http://launchpad.dev/~')
     view = removeSecurityProxy(view)
     self.assertEqual(canonical_url(person), view.target.rstrip('/'))
Exemplo n.º 7
0
 def test_support(self):
     # The /support link redirects to answers.
     context, view, request = test_traverse('http://launchpad.dev/support')
     view()
     self.assertEqual(301, request.response.getStatus())
     self.assertEqual('http://answers.launchpad.dev/launchpad',
                      request.response.getHeader('location'))
Exemplo n.º 8
0
 def test_feedback(self):
     # The /feedback link redirects to the help site.
     context, view, request = test_traverse('http://launchpad.dev/feedback')
     view()
     self.assertEqual(301, request.response.getStatus())
     self.assertEqual('https://help.launchpad.net/Feedback',
                      request.response.getHeader('location'))
Exemplo n.º 9
0
 def test_self_url_pathinfo(self):
     # You can traverse below /~/.
     person = self.factory.makePerson()
     login_person(person)
     obj, view, req = test_traverse('http://launchpad.dev/~/+editsshkeys')
     view = removeSecurityProxy(view)
     self.assertEqual(canonical_url(person) + '/+editsshkeys', view.target)
Exemplo n.º 10
0
 def test_livefs(self):
     livefs = self.factory.makeLiveFS()
     obj, _, _ = test_traverse(
         "http://launchpad.dev/~%s/+livefs/%s/%s/%s" %
         (livefs.owner.name, livefs.distro_series.distribution.name,
          livefs.distro_series.name, livefs.name))
     self.assertEqual(livefs, obj)
Exemplo n.º 11
0
 def test_traverse_stores_the_path(self):
     login(ANONYMOUS)
     object, view, request = test_traverse(
         'http://launchpad.dev/+yuitest/'
         'lib/lp/testing/tests/test_yuixhr_fixture.js')
     self.assertEquals('lib/lp/testing/tests/test_yuixhr_fixture.js',
                       removeSecurityProxy(view).traversed_path)
 def test_latestbuild_known_arch(self):
     # +latestbuild redirects to the most recent build for the requested
     # architecture.
     dspr_url, builds = self.setUpLatestBuildTests()
     _, view, _ = test_traverse("%s/+latestbuild/arch" % dspr_url)
     self.assertEqual(canonical_url(builds[1]),
                      removeSecurityProxy(view).target)
     self.assertEqual(303, removeSecurityProxy(view).status)
Exemplo n.º 13
0
 def test_traverse_simple(self):
     # test_traverse called with a product URL returns the product
     # as the traversed object.
     login(ANONYMOUS)
     product = self.factory.makeProduct()
     context, view, request = test_traverse(
         'https://launchpad.dev/' + product.name)
     self.assertEqual(product, context)
Exemplo n.º 14
0
 def test_traverse_quoted(self):
     # test_traverse decodes percent-encoded segments in URLs when
     # constructing PATH_INFO so that traversal works.
     login(ANONYMOUS)
     product = self.factory.makeProduct(name='foo+bar')
     context, view, request = test_traverse('https://launchpad.dev/' +
                                            quote(product.name))
     self.assertEqual(product, context)
Exemplo n.º 15
0
 def assertCodeViewClass(self, vcs, cls):
     distro = self.factory.makeDistribution(vcs=vcs)
     dsp = self.factory.makeDistributionSourcePackage(distribution=distro)
     self.assertEqual(vcs, distro.vcs)
     view = test_traverse(
         '/%s/+source/%s/+code'
         % (distro.name, dsp.sourcepackagename.name))[1]
     self.assertIsInstance(view, cls)
Exemplo n.º 16
0
 def test_self_url_app_domain(self):
     # You can traverse below /~/.
     person = self.factory.makePerson()
     login_person(person)
     obj, view, req = test_traverse('http://bugs.launchpad.dev/~')
     view = removeSecurityProxy(view)
     self.assertEqual(canonical_url(person, rootsite='bugs'),
                      view.target.rstrip('/'))
 def test_feedback(self):
     # The /feedback link redirects to the help site.
     context, view, request = test_traverse(
         'http://launchpad.dev/feedback')
     view()
     self.assertEqual(301, request.response.getStatus())
     self.assertEqual(
         'https://help.launchpad.net/Feedback',
         request.response.getHeader('location'))
Exemplo n.º 18
0
 def test_self_url_app_domain(self):
     # You can traverse below /~/.
     person = self.factory.makePerson()
     login_person(person)
     obj, view, req = test_traverse('http://bugs.launchpad.dev/~')
     view = removeSecurityProxy(view)
     self.assertEqual(
         canonical_url(person, rootsite='bugs'),
         view.target.rstrip('/'))
Exemplo n.º 19
0
 def test_service_traversal(self):
     # Test that traversal to the named service works.
     login(ANONYMOUS)
     fake_service = FakeService()
     self.registerUtility(fake_service, IService, "fake")
     context, view, request = test_traverse(
         'https://launchpad.dev/api/devel/+services/fake')
     self.assertEqual(getUtility(IServiceFactory), context)
     self.assertEqual(fake_service, view)
Exemplo n.º 20
0
 def test_self_url_pathinfo(self):
     # You can traverse below /~/.
     person = self.factory.makePerson()
     login_person(person)
     obj, view, req = test_traverse('http://launchpad.dev/~/+editsshkeys')
     view = removeSecurityProxy(view)
     self.assertEqual(
         canonical_url(person) + '/+editsshkeys',
         view.target)
 def test_support(self):
     # The /support link redirects to answers.
     context, view, request = test_traverse(
         'http://launchpad.dev/support')
     view()
     self.assertEqual(301, request.response.getStatus())
     self.assertEqual(
         'http://answers.launchpad.dev/launchpad',
         request.response.getHeader('location'))
Exemplo n.º 22
0
 def test_self_url_traversal(self):
     # Just /~/ expands to the current user.  (Bug 785800).
     person = self.factory.makePerson()
     login_person(person)
     obj, view, req = test_traverse('http://launchpad.dev/~')
     view = removeSecurityProxy(view)
     self.assertEqual(
         canonical_url(person),
         view.target.rstrip('/'))
Exemplo n.º 23
0
 def test_service_traversal(self):
     # Test that traversal to the named service works.
     login(ANONYMOUS)
     fake_service = FakeService()
     self.registerUtility(fake_service, IService, "fake")
     context, view, request = test_traverse(
         'https://launchpad.dev/api/devel/+services/fake')
     self.assertEqual(getUtility(IServiceFactory), context)
     self.assertEqual(fake_service, view)
Exemplo n.º 24
0
 def test_traversal_to_nonexistent_bugtask_on_api(self):
     # Traversing to a non-existent bugtask on the API redirects to
     # the default bugtask, but also on the API.
     bug = self.factory.makeBug()
     product = self.factory.makeProduct()
     obj, view, request = test_traverse(
         'http://api.launchpad.dev/1.0/%s/+bug/%d' %
         (product.name, bug.default_bugtask.bug.id))
     self.assertEqual(
         removeSecurityProxy(view).target,
         'http://api.launchpad.dev/1.0/%s/+bug/%d' %
         (bug.default_bugtask.target.name, bug.default_bugtask.bug.id))
Exemplo n.º 25
0
 def assertCodeViewClass(self, vcs, cls):
     person = self.factory.makePerson()
     distro = self.factory.makeDistribution(vcs=vcs)
     dsp = self.factory.makeDistributionSourcePackage(distribution=distro)
     self.assertEqual(vcs, distro.vcs)
     try:
         view = test_traverse(
             '~%s/%s/+source/%s/+code'
             % (person.name, distro.name, dsp.sourcepackagename.name))[1]
     except NotFound:
         view = None
     self.assertIsInstance(view, cls)
Exemplo n.º 26
0
    def test_request_is_current_during_traversal(self):
        # The request that test_traverse creates is current during
        # traversal in the sense of get_current_browser_request.
        login(ANONYMOUS)
        requests = []

        def record_current_request():
            requests.append(get_current_browser_request())
        context, view, request = test_traverse(
            self.registerViewCallable(record_current_request))
        self.assertEqual(1, len(requests))
        self.assertIs(request, requests[0])
Exemplo n.º 27
0
    def test_uses_current_user(self):
        # test_traverse performs the traversal as the currently logged
        # in user.
        person = self.factory.makePerson()
        login_person(person)
        users = []

        def record_user():
            users.append(getUtility(ILaunchBag).user)
        context, view, request = test_traverse(
            self.registerViewCallable(record_user))
        self.assertEqual(1, len(users))
        self.assertEqual(person, users[0])
Exemplo n.º 28
0
 def test_traversal_to_nonexistent_bugtask(self):
     # Test that a traversing to a non-existent bugtask redirects to the
     # bug's default bugtask.
     bug = self.factory.makeBug()
     bugtask = self.factory.makeBugTask(bug=bug)
     bugtask_url = canonical_url(bugtask, rootsite='bugs')
     login_person(bugtask.owner)
     bugtask.delete()
     obj, view, request = test_traverse(bugtask_url)
     view()
     naked_view = removeSecurityProxy(view)
     self.assertEqual(301, request.response.getStatus())
     self.assertEqual(naked_view.target,
                      canonical_url(bug.default_bugtask, rootsite='bugs'))
 def test_traversal_to_nonexistent_bugtask(self):
     # Test that a traversing to a non-existent bugtask redirects to the
     # bug's default bugtask.
     bug = self.factory.makeBug()
     bugtask = self.factory.makeBugTask(bug=bug)
     bugtask_url = canonical_url(bugtask, rootsite='bugs')
     login_person(bugtask.owner)
     bugtask.delete()
     obj, view, request = test_traverse(bugtask_url)
     view()
     naked_view = removeSecurityProxy(view)
     self.assertEqual(301, request.response.getStatus())
     self.assertEqual(
         naked_view.target,
         canonical_url(bug.default_bugtask, rootsite='bugs'))
Exemplo n.º 30
0
 def getBreadcrumbsForUrl(self, url):
     obj, view, request = test_traverse(url)
     view = create_initialized_view(obj, '+hierarchy', request=request)
     return view.items
Exemplo n.º 31
0
 def assertCodeViewClass(self, vcs, cls):
     distro = self.factory.makeDistribution(vcs=vcs)
     self.assertEqual(vcs, distro.vcs)
     view = test_traverse('/%s/+code' % distro.name)[1]
     self.assertIsInstance(view, cls)
Exemplo n.º 32
0
 def traverse_and_call():
     view = test_traverse(path)[1]
     view()
Exemplo n.º 33
0
 def assertCodeViewClass(self, vcs, cls):
     person = self.factory.makePerson()
     product = self.factory.makeProduct(vcs=vcs)
     self.assertEqual(vcs, product.vcs)
     view = test_traverse('/~%s/%s/+code' % (person.name, product.name))[1]
     self.assertIsInstance(view, cls)
Exemplo n.º 34
0
 def getBreadcrumbsForUrl(self, url):
     obj, view, request = test_traverse(url)
     view = create_initialized_view(obj, '+hierarchy', request=request)
     return view.items
Exemplo n.º 35
0
 def test_processor_navigation(self):
     quantum = self.factory.makeProcessor('quantum')
     obj, view, request = test_traverse(
         'http://api.launchpad.dev/devel/+processors/quantum')
     self.assertEquals(quantum, obj)
Exemplo n.º 36
0
 def test_processor_navigation(self):
     quantum = self.factory.makeProcessor('quantum')
     obj, view, request = test_traverse(
         'http://api.launchpad.dev/devel/+processors/quantum')
     self.assertEqual(quantum, obj)