Internet contact info
========================

Implementation of a behavior providing common used contact info

Test Internet Contact Info
---------------------------

When we create a dexterity content type::

    >>> from plone.dexterity.fti import DexterityFTI
    >>> from collective.behavior.contactinfo.behavior.contactinfo import INetContactInfo
    >>> fti = DexterityFTI('simple_type')
    >>> fti.behaviors = ('collective.behavior.contactinfo.behavior.contactinfo.INetContactInfo',)
    >>> self.portal.portal_types._setObject('simple_type', fti)
    'simple_type'
    >>> schema = fti.lookupSchema()

If we access the site as an admin TTW::

    >>> from Products.Five.testbrowser import Browser
    >>> browser = Browser()
    >>> browser.handleErrors = False
    >>> self.app.acl_users.userFolderAddUser('root', 'secret', ['Manager'], [])
    >>> browser.addHeader('Authorization', 'Basic root:secret')

We can see this type in the addable types at the root of the site::

    >>> browser.open("http://nohost/plone/folder_factories")
    >>> "simple_type" in browser.contents
    True
    >>> browser.getControl("simple_type").click()
    >>> browser.getControl("Add").click()
    >>> browser.getControl(name="form.widgets.title").value = "Foo"
    >>> browser.getControl(name="form.widgets.INetContactInfo.email").value = "email@domain.com"
    >>> browser.getControl(name="form.widgets.INetContactInfo.twitter").value = "@bomdiaporque"
    >>> browser.getControl(name="form.widgets.INetContactInfo.irc_nickname").value = "bomdiaporque"
    >>> browser.getControl(name="form.widgets.INetContactInfo.site").value = "http://domain.com"
    >>> browser.getControl(name="form.buttons.save").click()
    >>> browser.url
    'http://nohost/plone/simple_type/view'

We can now access our type and its values::

    >>> "http://nohost/plone/author/root" in browser.contents
    True
    >>> md = self.portal.simple_type
    >>> info_adapter = INetContactInfo(md, None)
    >>> info_adapter is not None
    True
    >>> info_adapter.email
    u'email@domain.com'
    >>> info_adapter.twitter
    u'@bomdiaporque'
    >>> info_adapter.irc_nickname
    u'bomdiaporque'
    >>> info_adapter.site
    'http://domain.com'
