==========
 Adresses
==========

There are several kinds of address types having constraints and titles.

Constraints
===========

The constraints ensure valid values for some address fields.

E-mail address
--------------

    >>> import icemac.addressbook.address
    >>> e = icemac.addressbook.address.EMailAddress()

Some failing examples first:

    >>> e.email = u'asdfg'
    Traceback (most recent call last):
    ConstraintNotSatisfied: asdfg
    >>> e.email = u'ich@'
    Traceback (most recent call last):
    ConstraintNotSatisfied: ich@
    >>> e.email = u'ich@goo@le.de'
    Traceback (most recent call last):
    ConstraintNotSatisfied: ich@goo@le.de
    >>> e.email = u'ich@local'
    Traceback (most recent call last):
    ConstraintNotSatisfied: ich@local
    >>> e.email = u'ich@local..de'
    Traceback (most recent call last):
    ConstraintNotSatisfied: ich@local..de
    >>> e.email = u'ich@local.de.'
    Traceback (most recent call last):
    ConstraintNotSatisfied: ich@local.de.

Now some working examples:

    >>> e.email = u'ich@example.org'
    >>> e.email = u'ich+du@example.org'
    >>> e.email = u'ich=du@example.org'
    >>> e.email = u'ich_du@example.org'
    >>> e.email = u'ich-du@example.org'
    >>> e.email = u'ich+du@a.b.c.d.example.org'
    >>> e.email = u'ich+du@example.museum'
    >>> e.email = u'ich@ex-ample.de'
    >>> e.email = u'ich@ex_ample.de'

Some examples from RFC 3696 (Note: not all examples from this RFC are
supported!):

    >>> e.email = u'user+mailbox@example.com'
    >>> e.email = u'customer/department=shipping@example.com'
    >>> e.email = u'$A12345@example.com'
    >>> e.email = u'!def!xyz%abc@example.com'
    >>> e.email = u'_somename@example.com'


Home page address
-----------------

    >>> a = icemac.addressbook.address.HomePageAddress()

Some failing examples first:

    >>> a.url = 'asdfg'
    Traceback (most recent call last):
    InvalidURI: asdfg
    >>> a.url = 'www.example.com'
    Traceback (most recent call last):
    InvalidURI: www.example.com


Now some working examples:

    >>> a.url = 'http://www.example.org'
    >>> a.url = 'http://www2.example.org'
    >>> a.url = 'http://a.b.c.d.example.org'
    >>> a.url = 'http://example.museum'


Titles
======

Each address type has a title adapter. Depending on the values set on
the address the computed title differs.


Postal address
--------------

    >>> import icemac.addressbook.interfaces
    >>> pa = icemac.addressbook.address.PostalAddress()

Germany is the default country, we like to reset it to get a really
empty address:

    >>> germany = pa.country
    >>> pa.country = None
    >>> icemac.addressbook.interfaces.ITitle(pa)
    u'none'

Setting attribute values leads to more telling titles:

   >>> pa.street = u'Papa street 3 a'
    >>> icemac.addressbook.interfaces.ITitle(pa)
    u'Papa street 3 a'

    >>> pa.address_prefix = u'c/o Mama'
    >>> icemac.addressbook.interfaces.ITitle(pa)
    u'c/o Mama, Papa street 3 a'

    >>> pa.zip = u'12345'
    >>> pa.city = u'Dingshausen'
    >>> pa.country = germany
    >>> icemac.addressbook.interfaces.ITitle(pa)
    u'c/o Mama, Papa street 3 a, 12345, Dingshausen, Germany'

E-mail address
--------------

    >>> ea = icemac.addressbook.address.EMailAddress()

The title of an empy e-mail address is a bit untelling:

    >>> icemac.addressbook.interfaces.ITitle(ea)
    u'none'

Setting attribute values leads to more telling titles:

    >>> ea.email = u'tester@example.org'
    >>> icemac.addressbook.interfaces.ITitle(ea)
    u'tester@example.org'

Home page address
-----------------

    >>> hp = icemac.addressbook.address.HomePageAddress()

The title of an empy home page address is a bit untelling:

    >>> icemac.addressbook.interfaces.ITitle(hp)
    u'none'

Setting attribute values leads to more telling titles:

   >>> hp.url = 'http://www.example.org'
    >>> icemac.addressbook.interfaces.ITitle(hp)
    u'http://www.example.org'

Phone number
------------

    >>> n = icemac.addressbook.address.PhoneNumber()

The title of an empy phone number is a bit untelling:

    >>> icemac.addressbook.interfaces.ITitle(n)
    u'none'

Setting attribute values leads to more telling titles:

    >>> n.number = u'+017912345678'
    >>> icemac.addressbook.interfaces.ITitle(n)
    u'+017912345678'
