Exemple #1
0
def test_adapter__exception_title__1(zcmlS):
    """It renders the exception manually instead of using str(exception).

    The latter is overwritten by Chameleon with a currently ugly and lengthy
    representation.
    """
    assert u'<KeyError(42,)>' == ITitle(KeyError(42))
def test_interfaces__PersonSource__getValue__2(address_book, search_data):
    """It returns only the persons in address book having `person_keyword`."""
    kw = zope.component.getUtility(IKeywords).get_keyword_by_title('church')
    # `search_data` yields an address_book instance which contains the person
    # data and is set as site, so we have to use it here:
    ICalendarDisplaySettings(ICalendar(search_data)).person_keyword = kw
    assert ([u'Koch', u'Velleuer', u'Liebig'
             ] == [ITitle(x) for x in PersonSource().factory.getValues()])
def test_address__postal_address_title__3(zcmlS):
    """`postal_address_title` is able to render the full address."""
    pa = PostalAddress()
    pa.address_prefix = u'c/o Mama'
    pa.street = u'Papa street 3 a'
    pa.zip = u'12345'
    pa.city = u'Dingshausen'
    assert (u'c/o Mama, Papa street 3 a, 12345, Dingshausen, Germany' ==
            ITitle(pa))
Exemple #4
0
def test_adapter__default_title__3(zcmlS):
    """It returns a the string representation of other objects."""
    assert ITitle(object()).startswith('<object object at 0x')
Exemple #5
0
def test_adapter__default_title__2(zcmlS):
    """It returns a unicode unchanged."""
    assert u'qwe' == ITitle(u'qwe')
def test_address__phone_number_title__2(zcmlS):
    """`phone_number_title` renders the home page URL if set."""
    n = PhoneNumber()
    n.number = u'+017912345678'
    assert u'+017912345678' == ITitle(n)
def test_person__title__2(zcmlS):
    """`title()` returns the last name if the first name is empty."""
    person = Person()
    person.last_name = u'Tester'
    assert u'Tester' == ITitle(person)
Exemple #8
0
def test_event__title__2(address_book, CategoryFactory, EventFactory):
    """It returns the category title if the alternative title is not set."""
    event = EventFactory(address_book,
                         category=CategoryFactory(address_book, u'birthday'))
    assert u'birthday' == ITitle(event)
def test_address__email_address_title__2(zcmlS):
    """`email_address_title` renders the email address if set."""
    ea = EMailAddress()
    ea.email = u'*****@*****.**'
    assert u'*****@*****.**' == ITitle(ea)
def test_address__email_address_title__1(zcmlS):
    """An empty email address has a title of 'none'."""
    assert u'none' == ITitle(EMailAddress())
def test_address__postal_address_title__2(zcmlS):
    """`postal_address_title` displays set parts of the address."""
    pa = PostalAddress()
    pa.street = u'Papa street 3 a'
    assert u'Papa street 3 a, Germany' == ITitle(pa)
def test_address__postal_address_title__1(zcmlS):
    """A really empty postal address has a title of 'none'."""
    pa = PostalAddress()
    pa.country = None  # reset default value of `Germany`
    assert u'none' == ITitle(pa)
def test_person__title__3(zcmlS):
    """`title()` returns the last name and first name comma separated."""
    person = Person()
    person.first_name = u'Hans'
    person.last_name = u'Tester'
    assert u'Tester, Hans' == ITitle(person)
Exemple #14
0
def test_adapter__default_title__1(zcmlS):
    """It returns a string unchanged."""
    assert 'asdf' == ITitle('asdf')
def test_address__home_page_address_title__1(zcmlS):
    """An empty home page address has a title of 'none'."""
    assert u'none' == ITitle(HomePageAddress())
def test_interfaces__PersonSource__getValue__1(address_book, search_data):
    """It returns all persons in address book if no `person_keyword` is set."""
    assert ([u'Hohmuth', u'Koch', u'Velleuer', u'Liebig', u'Tester, Liese'
             ] == [ITitle(x) for x in PersonSource().factory.getValues()])
def test_address__home_page_address_title__2(zcmlS):
    """`home_page_address_title` renders the home page URL if set."""
    hp = HomePageAddress()
    hp.url = 'http://www.example.org'
    assert u'http://www.example.org' == ITitle(hp)
    assert isinstance(ITitle(hp), six.text_type)
Exemple #18
0
def test_event__title__1(address_book, EventFactory):
    """It returns the alternative title if it is set."""
    event = EventFactory(address_book, alternative_title=u'alt-title')
    assert u'alt-title' == ITitle(event)
def test_address__phone_number_title__1(zcmlS):
    """An empty phone number has a title of 'none'."""
    assert u'none' == ITitle(PhoneNumber())
Exemple #20
0
def test_event__title__3(address_book, EventFactory):
    """It returns a string if neither alt. title nor category are set."""
    assert u'event' == ITitle(EventFactory(address_book))
def test_person__title__1(zcmlS):
    """The title of a person without a name is a fix string."""
    assert u'<no name>' == ITitle(Person())