def test_related_contacts_behavior_view_for_contact(self): add_behavior('Event', IRelatedContacts.__identifier__) timezone = 'Europe/Brussels' now = datetime.datetime.now() self.event = api.content.create( container=self.portal, type='Event', id='event') self.event.timezone = timezone eventbasic = IEventBasic(self.event) eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18) eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21) self.event.reindexObject() view = getMultiAdapter( (self.event, self.request), name='event_summary') person, organization1, organization2 = add_test_contents(self.portal) # set related contact intids = getUtility(IIntIds) to_id = intids.getId(organization1) rv = RelationValue(to_id) self.event.contact = rv self.assertEqual( view.get_website(organization1), None ) organization1.website = 'www.foo.bar' self.assertEqual( view.get_website(organization1), '<a class="event_website" href="http://www.foo.bar" target="_blank">www.foo.bar</a>' # noqa )
def test_phone_or_cellphone(self): add_behavior('Event', IRelatedContacts.__identifier__) timezone = 'Europe/Brussels' now = datetime.datetime.now() self.event = api.content.create( container=self.portal, type='Event', id='event') self.event.timezone = timezone eventbasic = IEventBasic(self.event) eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18) eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21) self.event.reindexObject() view = getMultiAdapter( (self.event, self.request), name='event_summary') person, organization1, organization2 = add_test_contents(self.portal) organization1.phone = ['081/586.100'] phone_or_cellphone = view.get_phone_or_cellphone(organization1) self.assertEqual(phone_or_cellphone[0].get('formated'), '+32 (0) 81 58 61 00') organization1.phone = [] phone_or_cellphone = view.get_phone_or_cellphone(organization1) self.assertEqual(len(phone_or_cellphone), 0) organization1.cell_phone = ['081/586.101'] phone_or_cellphone = view.get_phone_or_cellphone(organization1) self.assertEqual(phone_or_cellphone[0].get('formated'), '+32 (0) 81 58 61 01')
def test_phone_or_cellphone(self): add_behavior('Event', IRelatedContacts.__identifier__) timezone = 'Europe/Brussels' now = datetime.datetime.now() self.event = api.content.create(container=self.portal, type='Event', id='event') self.event.timezone = timezone eventbasic = IEventBasic(self.event) eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18) eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21) self.event.reindexObject() view = getMultiAdapter((self.event, self.request), name='event_summary') person, organization1, organization2 = add_test_contents(self.portal) organization1.phone = ['081/586.100'] phone_or_cellphone = view.get_phone_or_cellphone(organization1) self.assertEqual(phone_or_cellphone[0].get('formated'), '+32 (0) 81 58 61 00') organization1.phone = [] phone_or_cellphone = view.get_phone_or_cellphone(organization1) self.assertEqual(len(phone_or_cellphone), 0) organization1.cell_phone = ['081/586.101'] phone_or_cellphone = view.get_phone_or_cellphone(organization1) self.assertEqual(phone_or_cellphone[0].get('formated'), '+32 (0) 81 58 61 01')
def test_related_contacts_behavior_view_for_partners(self): add_behavior('Event', IRelatedContacts.__identifier__) timezone = 'Europe/Brussels' now = datetime.datetime.now() self.event = api.content.create( container=self.portal, type='Event', id='event') self.event.timezone = timezone eventbasic = IEventBasic(self.event) eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18) eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21) self.event.reindexObject() view = getMultiAdapter( (self.event, self.request), name='event_summary') self.assertNotIn('partners', view()) person, organization1, organization2 = add_test_contents(self.portal) # set related contact intids = getUtility(IIntIds) to_id1 = intids.getId(person) to_id2 = intids.getId(organization2) rv1 = RelationValue(to_id1) rv2 = RelationValue(to_id2) self.event.partners = [rv1, rv2] self.assertIn('partners', view())
def test_related_contacts_behavior_view_for_contact(self): add_behavior('Event', IRelatedContacts.__identifier__) timezone = 'Europe/Brussels' now = datetime.datetime.now() self.event = api.content.create(container=self.portal, type='Event', id='event') self.event.timezone = timezone eventbasic = IEventBasic(self.event) eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18) eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21) self.event.reindexObject() view = getMultiAdapter((self.event, self.request), name='event_summary') person, organization1, organization2 = add_test_contents(self.portal) # set related contact intids = getUtility(IIntIds) to_id = intids.getId(organization1) rv = RelationValue(to_id) self.event.contact = rv self.assertEqual(view.get_website(organization1), None) organization1.website = 'www.foo.bar' self.assertEqual( view.get_website(organization1), '<a class="event_website" href="http://www.foo.bar" target="_blank">www.foo.bar</a>' # noqa )
def test_related_contacts_behavior_view_for_partners(self): add_behavior('Event', IRelatedContacts.__identifier__) timezone = 'Europe/Brussels' now = datetime.datetime.now() self.event = api.content.create(container=self.portal, type='Event', id='event') self.event.timezone = timezone eventbasic = IEventBasic(self.event) eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18) eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21) self.event.reindexObject() view = getMultiAdapter((self.event, self.request), name='event_summary') self.assertNotIn('partners', view()) person, organization1, organization2 = add_test_contents(self.portal) # set related contact intids = getUtility(IIntIds) to_id1 = intids.getId(person) to_id2 = intids.getId(organization2) rv1 = RelationValue(to_id1) rv2 = RelationValue(to_id2) self.event.partners = [rv1, rv2] self.assertIn('partners', view())
def set_event_fields(self, obj, data): self.set_fields(obj, data) # event = IEventBasic(obj) start = DateTime(data["startDate"]["value"]) event.start = self.format_datetime(start) end = DateTime(data["endDate"]["value"]) event.end = self.format_datetime(end) event.timezone = 'CET'
def test_event_view_without_behavior(self): timezone = 'Europe/Brussels' now = datetime.datetime.now() self.event = api.content.create(container=self.portal, type='Event', id='event') self.event.timezone = timezone self.event.location = u'Mon adresse' eventbasic = IEventBasic(self.event) eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18) eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21) self.event.reindexObject() view = getMultiAdapter((self.event, self.request), name='event_summary') self.assertNotIn('partners', view())
def test_event_view_without_behavior(self): timezone = 'Europe/Brussels' now = datetime.datetime.now() self.event = api.content.create( container=self.portal, type='Event', id='event') self.event.timezone = timezone self.event.location = u'Mon adresse' eventbasic = IEventBasic(self.event) eventbasic.start = datetime.datetime(now.year, now.month, now.day, 18) eventbasic.end = datetime.datetime(now.year, now.month, now.day, 21) self.event.reindexObject() view = getMultiAdapter( (self.event, self.request), name='event_summary') self.assertNotIn('partners', view())