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


 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/ 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

    >>> 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

    >>> + '/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".


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")

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

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

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.getLink(id='registration').click()
    >>> browser.getControl(name='title').value = "Registration"
    >>> browser.getControl(name='text').value = "<b>About this registration</b>"
    >>> browser.getControl(name='').click()

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

    >>> 'registration' in self.portal.objectIds()
    >>> registration = self.portal['registration']
    >>> registration.title
    >>> 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.getLink(id='registrant').click()
    >>> browser.getControl(name='title').value = "Erika Mustermann"
    >>> browser.getControl(name='description').value = "Heidestr. 17, Berlin"
    >>> browser.getControl(name='email').value = ""
    >>> browser.getControl(name='').click()

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

    'Erika Mustermann'
    >>> rem.address
    'Heidestr. 17, Berlin'

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.getLink("Erika Mustermann").url == registration_url + '/erika-mustermann'
    >>> 'Heidestr. 17, Berlin' in browser.contents