~mars/launchpad/ghost-line

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Jelmer Vernooij, Henning Eggers, Aaron Bentley, Stuart Bishop, Graham Binns, Tim Penhey, Launchpad Patch Queue Manager, Gary Poster, William Grant, Edwin Grubbs, Robert Collins, j.c.sackett, Abel Deuring, Jonathan Lange, Jeroen Vermeulen, Julian Edwards, Curtis Hovey, Paul Hummer, Brian Murray, Maris Fogels, Danilo Segan, Deryck Hodge, Bryce Harrington, James Westby, Ian Booth, Gavin Panella, LaMont Jones, Danilo Šegan, Francis J. Lacoste, Benji York, Guilherme Salgado, Brad Crittenden, James Westby, Michael Nelson, Henning Eggers, Steve Kowalik, Michael Hudson, Diogo Matsubara, Steve Kowalik, Leonard Richardson, John Arbash Meinel, Ursula Junque, Andrew Mitchell, Anthony Lenton, Martin Pool, Colin Watson, Matthew Revell
  • Date: 2010-12-16 02:19:53 UTC
  • mfrom: (11782.13.2 test-ghost-update)
  • Revision ID: tarmac@sapote-20101216021953-24h56by3bwd0yrx6
[ui=none][r=mars][no-qa] Update to the latest devel

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
from zope.security.proxy import removeSecurityProxy
46
46
from zope.testbrowser.testing import Browser
47
47
 
48
 
from canonical.launchpad.interfaces import (
49
 
    ILaunchpadCelebrities,
 
48
from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
 
49
from canonical.launchpad.interfaces.oauth import (
50
50
    IOAuthConsumerSet,
51
51
    OAUTH_REALM,
52
 
    TeamMembershipStatus,
53
52
    )
54
53
from canonical.launchpad.testing.systemdocs import (
55
54
    LayeredDocFileSuite,
62
61
from canonical.launchpad.webapp.url import urlsplit
63
62
from canonical.testing.layers import PageTestLayer
64
63
from lp.registry.errors import NameAlreadyTaken
 
64
from lp.registry.interfaces.teammembership import TeamMembershipStatus
65
65
from lp.testing import (
66
66
    ANONYMOUS,
67
67
    launchpadlib_for,
319
319
            print sep.join(row_content)
320
320
 
321
321
 
322
 
def print_radio_button_field(content, name):
323
 
    """Find the input called field.name, and print a friendly representation.
 
322
def get_radio_button_text_for_field(soup, name):
 
323
    """Find the input called field.name, and return an iterable of strings.
324
324
 
325
325
    The resulting output will look something like:
326
 
    (*) A checked option
327
 
    ( ) An unchecked option
 
326
    ['(*) A checked option', '( ) An unchecked option']
328
327
    """
329
 
    main = BeautifulSoup(content)
330
 
    buttons = main.findAll(
 
328
    buttons = soup.findAll(
331
329
        'input', {'name': 'field.%s' % name})
332
330
    for button in buttons:
333
331
        if button.parent.name == 'label':
334
332
            label = extract_text(button.parent)
335
333
        else:
336
334
            label = extract_text(
337
 
                main.find('label', attrs={'for': button['id']}))
 
335
                soup.find('label', attrs={'for': button['id']}))
338
336
        if button.get('checked', None):
339
337
            radio = '(*)'
340
338
        else:
341
339
            radio = '( )'
342
 
        print radio, label
 
340
        yield "%s %s" % (radio, label)
 
341
 
 
342
 
 
343
def print_radio_button_field(content, name):
 
344
    """Find the input called field.name, and print a friendly representation.
 
345
 
 
346
    The resulting output will look something like:
 
347
    (*) A checked option
 
348
    ( ) An unchecked option
 
349
    """
 
350
    main = BeautifulSoup(content)
 
351
    for field in get_radio_button_text_for_field(main, name):
 
352
        print field
343
353
 
344
354
 
345
355
def strip_label(label):