def test_migrate_fields(self): tz = pytz.timezone('Europe/Berlin') e1 = createContentInContainer( self.portal, 'Event', title='event1', start=tz.localize(datetime(2011, 11, 11, 11, 0)), end=tz.localize(datetime(2011, 11, 11, 12, 0)), ) # Fill the field values into the annotation storage ann = IAnnotations(e1) ann['plone.app.event.dx.behaviors.IEventLocation.location'] = \ self.location ann['plone.app.event.dx.behaviors.IEventAttendees.attendees'] = \ self.attendees ann['plone.app.event.dx.behaviors.IEventContact.contact_email'] = \ self.contact_email ann['plone.app.event.dx.behaviors.IEventContact.contact_name'] = \ self.contact_name ann['plone.app.event.dx.behaviors.IEventContact.contact_phone'] = \ self.contact_phone ann['plone.app.event.dx.behaviors.IEventContact.event_url'] = \ self.event_url ann['plone.app.event.dx.behaviors.IEventSummary.text'] = \ RichTextValue(raw=self.text) # All behavior-related fields are not set yet self.assertEqual(e1.location, None) self.assertEqual(e1.attendees, ()) self.assertEqual(e1.contact_email, None) self.assertEqual(e1.contact_name, None) self.assertEqual(e1.contact_phone, None) self.assertEqual(e1.event_url, None) self.assertEqual(e1.text, None) # Run the upgrade step upgrade_attribute_storage(self.portal) # All behavior-related fields have been migrated self.assertEqual(e1.location, self.location) self.assertEqual(e1.attendees, self.attendees) self.assertEqual(e1.contact_email, self.contact_email) self.assertEqual(e1.contact_name, self.contact_name) self.assertEqual(e1.contact_phone, self.contact_phone) self.assertEqual(e1.event_url, self.event_url) self.assertEqual(e1.text.raw, self.text)
def test_migrate_fields(self): tz = pytz.timezone('Europe/Berlin') e1 = createContentInContainer( self.portal, 'Event', title=u'event1', start=tz.localize(datetime(2011, 11, 11, 11, 0)), end=tz.localize(datetime(2011, 11, 11, 12, 0)), ) # Fill the field values into the annotation storage ann = IAnnotations(e1) ann['plone.app.event.dx.behaviors.IEventLocation.location'] = \ self.location ann['plone.app.event.dx.behaviors.IEventAttendees.attendees'] = \ self.attendees ann['plone.app.event.dx.behaviors.IEventContact.contact_email'] = \ self.contact_email ann['plone.app.event.dx.behaviors.IEventContact.contact_name'] = \ self.contact_name ann['plone.app.event.dx.behaviors.IEventContact.contact_phone'] = \ self.contact_phone ann['plone.app.event.dx.behaviors.IEventContact.event_url'] = \ self.event_url ann['plone.app.event.dx.behaviors.IEventSummary.text'] = \ RichTextValue(raw=self.text) # All behavior-related fields are not set yet self.assertEqual(e1.location, None) self.assertEqual(e1.attendees, ()) self.assertEqual(e1.contact_email, None) self.assertEqual(e1.contact_name, None) self.assertEqual(e1.contact_phone, None) self.assertEqual(e1.event_url, None) self.assertEqual(e1.text, None) # Run the upgrade step upgrade_attribute_storage(self.portal) # All behavior-related fields have been migrated self.assertEqual(e1.location, self.location) self.assertEqual(e1.attendees, self.attendees) self.assertEqual(e1.contact_email, self.contact_email) self.assertEqual(e1.contact_name, self.contact_name) self.assertEqual(e1.contact_phone, self.contact_phone) self.assertEqual(e1.event_url, self.event_url) self.assertEqual(e1.text.raw, self.text)
def test_no_overwrite(self): tz = pytz.timezone('Europe/Berlin') e1 = createContentInContainer( self.portal, 'Event', title='event1', start=tz.localize(datetime(2011, 11, 11, 11, 0)), end=tz.localize(datetime(2011, 11, 11, 12, 0)), ) # Fill the field values into the annotation storage ann = IAnnotations(e1) ann['plone.app.event.dx.behaviors.IEventLocation.location'] = \ self.location + u'X' ann['plone.app.event.dx.behaviors.IEventAttendees.attendees'] = \ self.attendees + (u'Paula',) ann['plone.app.event.dx.behaviors.IEventContact.contact_email'] = \ self.contact_email + u'X' ann['plone.app.event.dx.behaviors.IEventContact.contact_name'] = \ self.contact_name + u'X' ann['plone.app.event.dx.behaviors.IEventContact.contact_phone'] = \ self.contact_phone + u'X' ann['plone.app.event.dx.behaviors.IEventContact.event_url'] = \ self.event_url + u'X' ann['plone.app.event.dx.behaviors.IEventSummary.text'] = \ RichTextValue(raw=self.text + u'X') # Add values into the fields in the new way e1.location = self.location e1.attendees = self.attendees e1.contact_email = self.contact_email e1.contact_phone = self.contact_phone e1.contact_name = self.contact_name e1.event_url = self.event_url e1.text = RichTextValue(raw=self.text) upgrade_attribute_storage(self.portal) # The already existing field values were not touched by the upgrade self.assertEqual(e1.location, self.location) self.assertEqual(e1.attendees, self.attendees) self.assertEqual(e1.contact_email, self.contact_email) self.assertEqual(e1.contact_phone, self.contact_phone) self.assertEqual(e1.contact_name, self.contact_name) self.assertEqual(e1.event_url, self.event_url) self.assertEqual(e1.text.raw, self.text)
def test_no_overwrite(self): tz = pytz.timezone('Europe/Berlin') e1 = createContentInContainer( self.portal, 'Event', title=u'event1', start=tz.localize(datetime(2011, 11, 11, 11, 0)), end=tz.localize(datetime(2011, 11, 11, 12, 0)), ) # Fill the field values into the annotation storage ann = IAnnotations(e1) ann['plone.app.event.dx.behaviors.IEventLocation.location'] = \ self.location + u'X' ann['plone.app.event.dx.behaviors.IEventAttendees.attendees'] = \ self.attendees + (u'Paula',) ann['plone.app.event.dx.behaviors.IEventContact.contact_email'] = \ self.contact_email + u'X' ann['plone.app.event.dx.behaviors.IEventContact.contact_name'] = \ self.contact_name + u'X' ann['plone.app.event.dx.behaviors.IEventContact.contact_phone'] = \ self.contact_phone + u'X' ann['plone.app.event.dx.behaviors.IEventContact.event_url'] = \ self.event_url + u'X' ann['plone.app.event.dx.behaviors.IEventSummary.text'] = \ RichTextValue(raw=self.text + u'X') # Add values into the fields in the new way e1.location = self.location e1.attendees = self.attendees e1.contact_email = self.contact_email e1.contact_phone = self.contact_phone e1.contact_name = self.contact_name e1.event_url = self.event_url e1.text = RichTextValue(raw=self.text) upgrade_attribute_storage(self.portal) # The already existing field values were not touched by the upgrade self.assertEqual(e1.location, self.location) self.assertEqual(e1.attendees, self.attendees) self.assertEqual(e1.contact_email, self.contact_email) self.assertEqual(e1.contact_phone, self.contact_phone) self.assertEqual(e1.contact_name, self.contact_name) self.assertEqual(e1.event_url, self.event_url) self.assertEqual(e1.text.raw, self.text)