The waeup package
********************

:Test-Layer: functional

University
==========

We can watch universities in the browser.

To make sure, we can 'watch' pages, we first have to initialize out
test browser::

  >>> from zope.testbrowser.testing import Browser
  >>> browser = Browser()
  >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
  >>> browser.handleErrors = False

We create an university object and put into the ZODB root::

  >>> root = getRootFolder()
  >>> list(root)
  []

  >>> from waeup.app import University
  >>> u = University()
  >>> root['myuniversity'] = u
  >>> list(root)
  [u'myuniversity']


Let's get the default view of a university::

  >>> browser.open('http://localhost/myuniversity')
  >>> print browser.contents
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
  ...<h1>Congratulations!</h1>...
  ...

We can also get an edit view of a university::

  >>> browser.open('http://localhost/myuniversity/edit')
  >>> print browser.contents
  <html>...
  ...<form action="http://localhost/myuniversity/edit"
  ...

The edit form contains the default value for the university name::

  >>> 'Unnamed' in browser.contents
  True

Faculties
=========

Wie can add faculties, by calling and submitting an add form of an
university. The add form can be retrieved by calling the
``addfaculty`` view of an university::

  >>> browser.open('http://localhost/myuniversity/addfaculty')
  >>> print browser.contents
  <html>...
  ...<span class="required">*</span><span>Name of Faculty</span>
  ...

We fill in a new name for our new faculty::

  >>> ctrl = browser.getControl(name='form.name')
  >>> ctrl.value = 'TestFac'

Finally we click on 'Add Faculty' to add the new thing::

  >>> browser.getControl('Add Faculty').click()
  >>> #print browser.contents

We can view a faculty by browsing a URL like this::

  >>> browser.open('http://localhost/myuniversity/TestFac')

Afterwards, the faculty should be visible:

  >>> browser.open('http://localhost/myuniversity/')
  >>> print browser.contents
  <html...
  ...<h2>Your faculties:</h2>
  ...<a href="http://localhost/myuniversity/TestFac">TestFac</a>
  ...



