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"...
  ...Welcome to the...
  ...

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

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

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

  >>> 'Sample University' in browser.contents
  True

We can export a university as XML::

  >>> browser.open('http://localhost/myuniversity/export.xml')
  >>> print browser.contents
  <?xml version="1.0" encoding="utf-8" ?>
  <pickle>
  ...
  </pickle>

  >>> print browser.headers
  Status: 200 Ok
  Content-Length: ...
  Content-Type: text/xml; charset=UTF-8
  X-Powered-By: Zope (www.zope.org), Python (www.python.org)


Faculties
=========

Faculties are stored in a special container of `IUniversity`
instances. The container is called ``faculties`` and provides an
add-form to add new faculties::

  >>> browser.open('http://localhost/myuniversity/faculties/add')
  >>> print browser.contents
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
  ...<span class="required">*</span><span>Name of Faculty</span>
  ...

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

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

Furthermore we add a prefix and a code (kind of abbreviation):

  >>> browser.getControl(name='form.code').value = 'TF'

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

  >>> browser.getControl('Add faculty').click()

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

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

Afterwards, the faculty should be visible:

  >>> browser.open('http://localhost/myuniversity/faculties')
  >>> print browser.contents
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
  ...<h2>Registered faculties:</h2>
  ...<a href="http://localhost/myuniversity/faculties/TF">TestFac</a>
  ...


Data Center
===========

The data center helps us uploading files for later import or similar.

  >>> browser.open('http://localhost/myuniversity')
  >>> browser.getLink('Data Center').click()

By default we have a directory in the sources for upload:

  >>> print browser.contents
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  ...
  Storage path: <span>/.../waeup/files</span>
  ...

