================================
Bugfix for address book entities
================================

There were some bugs when using entities.


Set up
======

Create a local adminstrator:

>>> from icemac.addressbook.testing import create_user, get_messages
>>> ab = layer['addressbook']
>>> create_user(
...     ab, ab, u'Ad', u'Min', u'ad@min.de', u'12345678', ('Administrator',))

Edit entities as local administrator
====================================

A local administrator was not able to edit the entities.

Log in as the local administrator and navigate to the edit entities
section of the master data:

>>> browser = get_browser()
>>> browser.open('http://localhost/ab')
>>> browser.getControl('User Name').value = 'ad@min.de'
>>> browser.getControl('Password').value = '12345678'
>>> browser.getControl('Log in').click()
>>> get_messages(browser)
['You have been logged-in successfully.']

>>> browser.getLink('Master data').click()
>>> browser.getLink('Entities').click()
>>> browser.url
'http://localhost/ab/++attribute++entities'
>>> print browser.contents
<!DOCTYPE ...
          <td>address book</td>
          ...
          <td>person</td>
          ...

Choice field values containing non ascii characters
===================================================

Choice field values could not contain non ascii characters.

Create a user defined choice field and a values containing a non ascii
character:

>>> browser.getLink('Edit fields', index=1).click()
>>> browser.url
'http://localh.../ab/++attribute++entities/icemac.addressbook.person.Person'
>>> browser.getLink('field').click()
>>> browser.getControl('type').displayValue = ['choice']
>>> browser.getControl('title').value = 'Ümläuttößt'
>>> browser.getControl('Add', index=0).click()
>>> get_messages(browser)
[]
>>> browser.getControl('value').value = 'Küche'
>>> browser.getControl('Add', index=1).click()
>>> get_messages(browser)
[u'"\xdcml\xe4utt\xf6\xdft" added.']
>>> browser.url
'http://localh.../ab/++attribute++entities/icemac.addressbook.person.Person'

The error occured when adding a new object for the entity with the user defined field (a person in our case):

>>> browser.getLink('Person list').click()
>>> browser.getLink('person').click()
>>> browser.getControl('Ümläuttößt').displayOptions
['No value', 'K\xc3\xbcche']
