waeup.hostel.HostelContainer
****************************

Containers for hostels.

:Test-Layer: unit

Getting a hostel container
==========================

We can easily create `HostelContainers`::

    >>> from waeup.hostel.hostelcontainer import HostelContainer
    >>> mycontainer = HostelContainer()

Hostel containers provide ``IHostelContainer``:

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

Another way to get a hostel container -- without importing the class
-- is via factories. We registered a factory for hostel containers
under the name ``waeup.HostelContainer``::

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

Now we can ask for an object by calling the appropriate factory:

    >>> from zope.component import createObject
    >>> createObject(u'waeup.HostelContainer')
    <waeup.hostel.hostelcontainer.HostelContainer object at 0x...>

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

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

    >>> from zope.interface.verify import verifyClass
    >>> verifyClass(IHostelContainer, HostelContainer)
    True


Storing things in hostel containers
====================================

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

    >>> mycontainer.addHostel(42)
    Traceback (most recent call last):
    ...
    TypeError: HostelContainers contain only IHostel instances

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

    >>> from waeup.hostel.hostel import Hostel
    >>> myhostel = Hostel()

We can add this hostel to our container::

    >>> mycontainer.addHostel(myhostel)
    '0'

We get back the key, under which the hostel 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.
