Certificates
************

:Test-Layer: unit

Creating certificates
=====================

Because certificates make use of components registered with the Zope
Component Architecture (ZCA), we first have to grok the `waeup`
package. This happens automatically in real-world use:

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

We can create certificates:

    >>> from waeup.university.certificate import Certificate
    >>> mycertificate = Certificate()
    >>> mycertificate
    <waeup.university.certificate.Certificate object at 0x...>

Another way to create certificates is by asking for a factory called
``waeup.Certificate``. This way we can create a factory without
importing a class:

    >>> from zope.component import createObject
    >>> mycertificate = createObject(u'waeup.Certificate')
    >>> mycertificate
    <waeup.university.certificate.Certificate object at 0x...>


Certificate attributes
======================

Certificates have the attributes required by the `ICertificate` interface:

    >>> from waeup.interfaces import ICertificate
    >>> ICertificate.providedBy(mycertificate)
    True

    >>> from zope.interface.verify import verifyObject
    >>> verifyObject(ICertificate, mycertificate)
    True

Each of the following attributes is mandatory.

`title`
-------

Each certificate has a title:

    >>> mycertificate.title
    u'Unnamed Certificate'

`code`
------

Each certificate holds a code, which might be a shortcut or abbreviation
of the real certificate name. By default the code is ``NA`` (=not assigned):

    >>> mycertificate.code
    u'NA'

`review_state`
--------------

The review state can have one of the ``checking`` states defined in
the WAeUP workflow. These are at least the states ``checked`` and
``unchecked``. After a certificate is created, the review state is
``unchecked``:

    >>> mycertificate.review_state
    'unchecked'

We can mark a certificate as checked:

    >>> mycertificate.check()
    >>> mycertificate.review_state
    'checked'

We cannot uncheck a certificate:

    >>> mycertificate.review_state = 'init'
