FacultyContainer
****************

Containers for faculties.

:Test-Layer: unit

Getting a faculty container
===========================

We can easily create `FacultyContainers`::

    >>> from waeup.university.facultycontainer import FacultyContainer
    >>> mycontainer = FacultyContainer()

Another way to get a faculty container -- without importing the class
-- is via utilities. FacultyContainer instances provide the
IFacultyContainer interface::

    >>> from waeup.interfaces import IFacultyContainer
    >>> IFacultyContainer.providedBy(mycontainer)
    True

Also a factory(-utility) is registered, so that we can ask for a
faculty container without importing one. To check this, we first have
to grok the `waeup` package. This is normally done during startup::

    >>> import grok
    >>> grok.testing.grok('waeup')

Now we can ask for an object providing `IFacultyContainer`::

    >>> from zope.component import getUtility
    >>> getUtility(IFacultyContainer)
    <waeup.university.facultycontainer.FacultyContainer object at 0x...>

This way we get a thing that implements IFacultyContainer without
imports or similar.

We can be sure, that the full interface is supported by the
FacultyContainer class::

    >>> from zope.interface.verify import verifyClass
    >>> verifyClass(IFacultyContainer, FacultyContainer)
    True


Storing things in faculty containers
====================================

We can, of course, store things in a faculty container. But when we
really store an object, then it must be a faculty::

    >>> mycontainer.addFaculty(42)
    Traceback (most recent call last):
    ...
    TypeError: FacultyContainers contain only IFaculty instances

Okay, so we have to get a faculty first::

    >>> from waeup.university.faculty import Faculty
    >>> myfaculty = Faculty()

We can add this faculty to our container::

    >>> mycontainer.addFaculty(myfaculty)
    '0'

We get back the key, under which the faculty was stored. It will be
some string, but there is no guarantee at all, how this key looks
like. It might be a string of integers, a name or whatever; you cannot
know before.
