README.txt

Plain Text icon README.txt — Plain Text, 4 KB (4234 bytes)

Dateiinhalt

========================
 vs.registration content
========================

This package contains content types that pertain to the vs.registration
application. In this testbrowser doctest, we will demonstrate how the content 
types interact. See tests/test_doctest.py for how it is set up.

Setting up and logging in
-------------------------

We use zope.testbrowser to simulate browser interaction in order to show
the main flow of pages. This is not a true functional test, because we also
inspect and modify the internal state of the ZODB, but it is a useful way of
making sure we test the full end-to-end process of creating and modifying
content.

    >>> from Products.Five.testbrowser import Browser
    >>> browser = Browser()
    >>> portal_url = self.portal.absolute_url()

The following is useful when writing and debugging testbrowser tests. It lets
us see error messages properly.

    >>> browser.handleErrors = False
    >>> self.portal.error_log._ignored_exceptions = ()

We log in as the portal owner, i.e. an administrator user. We
do this from the login page.

    >>> from Products.PloneTestCase.setup import portal_owner, default_password

    >>> browser.open(portal_url + '/login_form?came_from=' + portal_url)
    >>> browser.getControl(name='__ac_name').value = portal_owner
    >>> browser.getControl(name='__ac_password').value = default_password
    >>> browser.getControl(name='submit').click()

Addable content
---------------

Registration content is managed inside two root content types: A "Registration"
contains "registrants".

    >>> browser.open(portal_url)

Verify that we have the links to create registration folders, from the add
item menu:

    >>> browser.getLink(id='registration').url.endswith("createObject?type_name=Registration")
    True

And likewise, we don't have add links for the other types

    >>> browser.getLink(id='registrant')
    Traceback (most recent call last):
    ...
    LinkNotFoundError


Adding registrations and registrants
------------------------------------

Let us now add a registration and some registrants. The registration
can contain a rich-text description of the registration (e.g. of a group
of registrants), which will be displayed on the front page of that folder.

    >>> browser.open(portal_url)
    >>> browser.getLink(id='registration').click()
    >>> browser.getControl(name='title').value = "Registration"
    >>> browser.getControl(name='text').value = "<b>About this registration</b>"
    >>> browser.getControl(name='form.button.save').click()

This should have added an object called 'registration' in the portal root, invoking
the title-to-id renaming.

    >>> 'registration' in self.portal.objectIds()
    True
    >>> registration = self.portal['registration']
    >>> registration.title
    'Registration'
    >>> registration.text
    '<b>About this registration</b>'

    >>> registration_url = registration.absolute_url()

Registration include a registrant. We will just populate them with
strings. There is also an address, which is mapped to the Description Dublin
Core metadata field, a email address, and some free text describing the registrant.

    >>> browser.open(registration_url)
    >>> browser.getLink(id='registrant').click()
    >>> browser.getControl(name='title').value = "Erika Mustermann"
    >>> browser.getControl(name='description').value = "Heidestr. 17, Berlin"
    >>> browser.getControl(name='email').value = "erika.mustermann@example.org"
    >>> browser.getControl(name='form.button.save').click()

    >>> 'erika-mustermann' in registration.objectIds()
    True
    >>> rem = registration['erika-mustermann']
    >>> rem_url = rem.absolute_url()

    >>> rem.name
    'Erika Mustermann'
    >>> rem.address
    'Heidestr. 17, Berlin'
    >>> rem.email
    'erika.mustermann@example.org'

The registration view should now be listing these two registrants, provided we
have the rights to see them, which we do as a manager user. For other users,
this will depend on workflow permissions, of course.

    >>> browser.open(registration_url)
    >>> browser.getLink("Erika Mustermann").url == registration_url + '/erika-mustermann'
    True
    >>> 'Heidestr. 17, Berlin' in browser.contents
    True