def test_calendar__EventDescription__getInfo__6(address_book, EventFactory, utc_time_zone_pref): """It omits empty string values.""" set_event_additional_fields(address_book, 'persons') ed = IEventDescription(EventFactory(address_book)) assert '' == ed.persons assert [] == ed.getInfo()
def test_calendar__EventDescription__getInfo__9(address_book, EventFactory, utc_time_zone_pref): """It hyphenates the text.""" set_event_additional_fields(address_book, 'text') ed = IEventDescription( EventFactory(address_book, text=u'I contain longer words.')) assert [u'I con­tain longer word­s.'] == ed.getInfo(lang='en')
def test_calendar__EventDescription__getInfo__5(address_book, EventFactory, utc_time_zone_pref): """It omits fields with a `None` value.""" set_event_additional_fields(address_book, 'text') ed = IEventDescription(EventFactory(address_book)) assert ed.context.text is None assert [] == ed.getInfo()
def test_calendar__EventDescription__getInfo__7(address_book, FieldFactory, EventFactory, utc_time_zone_pref): """It does not omit numbers with the value of zero.""" num_field = FieldFactory(address_book, IEvent, u'Int', u'num').__name__ set_event_additional_fields(address_book, num_field) ed = IEventDescription(EventFactory(address_book, **{num_field: 0})) assert [u'0'] == ed.getInfo()
def test_calendar__EventDescription__getInfo__8(address_book, PersonFactory, EventFactory, utc_time_zone_pref): """It returns external and internal persons if `persons` is selected.""" p1 = PersonFactory(address_book, u'Tester', first_name=u'Hans') set_event_additional_fields(address_book, 'persons') ed = IEventDescription( EventFactory(address_book, persons=set([p1]), external_persons=[u'Franz Vrozzek', u'Fritz Vrba'])) assert [u'Franz Vrozzek, Fritz Vrba, Hans Tester'] == ed.getInfo()
def test_calendar__EventDescription__getInfo__3(address_book, FieldFactory, EventFactory, utc_time_zone_pref): """It returns a list of the selected fields as unicode objects.""" reservations = FieldFactory(address_book, IEvent, u'Int', u'reservations').__name__ # Both user fields and pre-defined fields are possible set_event_additional_fields(address_book, 'text', reservations) ed = IEventDescription( EventFactory(address_book, **{ 'text': u'Event is not yet sure.', reservations: 50 })) assert [u'Event is not yet sure.', u'50'] == ed.getInfo()
def test_calendar__EventDescription__getInfo__2(address_book, EventFactory, DateTime, CategoryFactory, selected_user_field, utc_time_zone_pref): """It ignores a selected but later deleted user defined field.""" ed = IEventDescription( EventFactory( address_book, **{ 'datetime': DateTime.now, 'text': u'Text1', 'category': CategoryFactory(address_book, u'bar'), selected_user_field: 42 })) event_entity = IEntity(IEvent) event_entity.removeField(event_entity.getRawField(selected_user_field)) assert ['Text1'] == ed.getInfo()
def get_table_event(event, field_names=[], request_kw={}): request = RequestFactory(**request_kw) event_entity = IEntity(IEvent) ICalendarDisplaySettings( address_book.calendar).event_additional_fields = [ event_entity.getRawField(x) for x in field_names ] event_description = IEventDescription(event) return zope.component.getMultiAdapter((event_description, request), name='table-event')
def test_calendar__EventDescription__getInfo__1(address_book, CategoryFactory, RecurringEventFactory, DateTime, selected_user_field, utc_time_zone_pref): """It ignores not existing fields. This happens if a user defined field is chosen for display but there is no equivalent field on the recurring event which is rendered as recurred event. """ recurring_event = RecurringEventFactory( address_book, **{ 'datetime': DateTime.now, 'text': u'Text2', 'period': 'daily', 'category': CategoryFactory(address_book, u'bar') }) ed = IEventDescription(get_recurred_event(recurring_event, DateTime)) assert ['Text2'] == ed.getInfo()
def test_calendar__EventDescription__getInfo__4(address_book, EventFactory, utc_time_zone_pref): """It splits the text field at line endings.""" set_event_additional_fields(address_book, 'text') ed = IEventDescription(EventFactory(address_book, text=u'foo\nbar')) assert [u'foo', u'bar'] == ed.getInfo()