Ejemplo n.º 1
0
def test_fields__get_field_customization__1(address_book, PersonFactory):
    """It returns the application customized title of a field, if

    there is no user customization.
    """
    person = PersonFactory(address_book, u'Vukasinovitch')
    field = zope.dublincore.interfaces.IDCTimes['created']
    adapter_factory = get_field_customization('label', 'label')
    with zope.publisher.testing.interaction('principal_1'):
        request = zope.security.management.getInteraction().participations[0]
        adapter = adapter_factory(person, request, None, field, None)
        assert u'Creation Date (${timezone})' == adapter.get()
Ejemplo n.º 2
0
def test_fields__get_field_customization__4(address_book, PersonFactory):
    """It returns `None` as adapter if

    there is no value set on the field interface.
    """
    person = PersonFactory(address_book, u'Vukasinovitch')
    field = icemac.addressbook.interfaces.IPersonName['first_name']

    adapter_factory = get_field_customization('description', 'title')
    with zope.publisher.testing.interaction('principal_1'):
        request = zope.security.management.getInteraction().participations[0]
        adapter = adapter_factory(person, request, None, field, None)
        assert adapter is None
Ejemplo n.º 3
0
def test_fields__get_field_customization__3(address_book, PersonFactory):
    """It returns the framework default title of a field, if

    there is no customization at all.
    """
    person = PersonFactory(address_book, u'Vukasinovitch')
    field = icemac.addressbook.metadata.interfaces.IEditor['creator']

    adapter_factory = get_field_customization('label', 'label')
    with zope.publisher.testing.interaction('principal_1'):
        request = zope.security.management.getInteraction().participations[0]
        adapter = adapter_factory(person, request, None, field, None)
        assert u'creator' == adapter.get()
Ejemplo n.º 4
0
def test_fields__get_field_customization__2(address_book, PersonFactory):
    """It returns the user customized title of a field, if

    there is a user customization.
    """
    person = PersonFactory(address_book, u'Vukasinovitch')
    field = zope.dublincore.interfaces.IDCTimes['created']

    customization = icemac.addressbook.interfaces.IFieldCustomization(
        address_book)
    customization.set_value(field, u'label', u'Custom Creation Date Label')

    adapter_factory = get_field_customization('label', 'label')
    with zope.publisher.testing.interaction('principal_1'):
        request = zope.security.management.getInteraction().participations[0]
        adapter = adapter_factory(person, request, None, field, None)
        assert u'Custom Creation Date Label' == adapter.get()
Ejemplo n.º 5
0
def test_fields__get_field_customization__5(
        address_book, FieldFactory, KeywordFactory):
    """It returns the description of a user defined field.

    It replaces newlines by spaces as the description is put into a TextLine
    field later on.
    """
    field = FieldFactory(
        address_book, icemac.addressbook.interfaces.IKeyword, u'Bool',
        u'usable?', notes=u'Is\nthis\rkeyword\r\nusable?')
    schema_field = zope.schema.interfaces.IField(field)
    keyword = KeywordFactory(address_book, u'Church')

    adapter_factory = get_field_customization('description', 'title')
    with zope.publisher.testing.interaction('principal_1'):
        request = zope.security.management.getInteraction().participations[0]
        adapter = adapter_factory(keyword, request, None, schema_field, None)
        result = adapter.get()
        assert ('Is this keyword  usable?' == result)
        assert isinstance(result, six.text_type)