~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/launchpad/testing/pages.py

  • Committer: Julian Edwards
  • Date: 2011-07-28 20:46:18 UTC
  • mfrom: (13553 devel)
  • mto: This revision was merged to the branch mainline in revision 13555.
  • Revision ID: julian.edwards@canonical.com-20110728204618-tivj2wx2oa9s32bx
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""Testing infrastructure for page tests."""
41
41
from zope.security.proxy import removeSecurityProxy
42
42
from zope.testbrowser.testing import Browser
43
43
 
 
44
from canonical.launchpad.interfaces.oauth import (
 
45
    IOAuthConsumerSet,
 
46
    OAUTH_REALM,
 
47
    )
 
48
from canonical.launchpad.testing.systemdocs import (
 
49
    LayeredDocFileSuite,
 
50
    stop,
 
51
    strip_prefix,
 
52
    )
44
53
from canonical.launchpad.webapp import canonical_url
45
54
from canonical.launchpad.webapp.interfaces import OAuthPermission
46
55
from canonical.launchpad.webapp.url import urlsplit
48
57
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
49
58
from lp.registry.errors import NameAlreadyTaken
50
59
from lp.registry.interfaces.teammembership import TeamMembershipStatus
51
 
from lp.services.oauth.interfaces import (
52
 
    IOAuthConsumerSet,
53
 
    OAUTH_REALM,
54
 
    )
55
60
from lp.testing import (
56
61
    ANONYMOUS,
57
62
    launchpadlib_for,
60
65
    logout,
61
66
    )
62
67
from lp.testing.factory import LaunchpadObjectFactory
63
 
from lp.testing.systemdocs import (
64
 
    LayeredDocFileSuite,
65
 
    stop,
66
 
    )
67
68
 
68
69
 
69
70
class UnstickyCookieHTTPCaller(HTTPCaller):
160
161
    default_api_version = "beta"
161
162
 
162
163
    def addHeadersTo(self, full_url, full_headers):
163
 
        if self.consumer is not None and self.access_token is not None:
 
164
        if (self.consumer is not None and self.access_token is not None):
164
165
            request = OAuthRequest.from_consumer_and_token(
165
 
                self.consumer, self.access_token, http_url=full_url)
166
 
            request.sign_request(
167
 
                OAuthSignatureMethod_PLAINTEXT(), self.consumer,
168
 
                self.access_token)
 
166
                self.consumer, self.access_token, http_url = full_url,
 
167
                )
 
168
            request.sign_request(OAuthSignatureMethod_PLAINTEXT(),
 
169
                                 self.consumer, self.access_token)
169
170
            full_headers.update(request.to_header(OAUTH_REALM))
170
171
        if not self.handle_errors:
171
172
            full_headers['X_Zope_handle_errors'] = 'False'
562
563
        for li_tag in comment('li'):
563
564
            print "Attachment: %s" % li_tag.a.renderContents()
564
565
        print comment.div.renderContents()
565
 
        print "-" * 40
 
566
        print "-"*40
566
567
 
567
568
 
568
569
def print_batch_header(soup):
851
852
    # files would be looked up relative to this module.
852
853
    package = doctest._normalize_module(package)
853
854
    abs_storydir = doctest._module_relative_path(package, storydir)
 
855
    stripped_storydir = strip_prefix(abs_storydir)
854
856
 
855
 
    filenames = set(
856
 
        filename
857
 
        for filename in os.listdir(abs_storydir)
858
 
        if filename.lower().endswith('.txt'))
 
857
    filenames = set(filename
 
858
                    for filename in os.listdir(abs_storydir)
 
859
                    if filename.lower().endswith('.txt'))
859
860
 
860
861
    suite = unittest.TestSuite()
861
862
    # Add tests to the suite individually.