Esempio n. 1
0
def create_user(client, username=username, password=password,
                fullname=fullname, email=email):
    """
    Fills out the join form, retrieves confirmation key and finalizes
    registration.
    """
    fill_out_join_form(client, username, password, fullname, email)
    client.asserts.assertNode(id=u'oc-deadend-message-container')
    client.asserts.assertNode(xpath=u'/html/body/div/div/div/div/div')
    # XXX this should work, but it fails
    #client.asserts.assertText(xpath=u'/html/body/div/div/div/div/div',
    #                          validator=u'Thanks for joining OpenPlans, %s!' % username)

    logger.info('Retrieving user confirmation key for %s' % username)
    portal = get_auth_portal()
    confirmation_code = getattr(portal.portal_memberdata,
                                username).getUserConfirmationCode()

    client.open(url="%s/confirm-account?key=%s" % (base_url,
                                                   confirmation_code))
    client.waits.forPageLoad()
    client.asserts.assertNode(xpath=u'/html/body/div/div/div/div/div/div/h1')
    client.asserts.assertText(xpath=u'/html/body/div/div/div/div/div/div/h1',
                              validator=u'Welcome to OpenPlans!')
    client.asserts.assertNode(link=u'Complete your profile')
    client.asserts.assertNode(id=u'ext-gen17')
    client.asserts.assertText(id=u'ext-gen17', validator=username)
    client.asserts.assertNode(link=u'Sign out')
Esempio n. 2
0
def zope_delobject(container_path, obj_id):
    """
    Deletes a Zope object:

    o container_path: path to the container of the object to be
    deleted, relative to the Plone site root

    o obj_id: id of the object to be deleted
    """
    portal = get_auth_portal()
    try:
        getattr(portal, container_path).manage_delObjects([obj_id])
    except Fault, e:
        ignorable = '%s does not exist' % obj_id
        if str(e).count(ignorable):
            print("(zope) can't delete %s/%s, it didn't exist" % (container_path,
                                                                  obj_id))
        else:
            print("Error removing '%s' from '%s': %s" % (obj_id,
                                                         container_path,
                                                         str(e)))