Back to index

plone3  3.1.7
test_atevent.py
Go to the documentation of this file.
00001 #  ATContentTypes http://plone.org/products/atcontenttypes/
00002 #  Archetypes reimplementation of the CMF core types
00003 #  Copyright (c) 2003-2006 AT Content Types development team
00004 #
00005 #  This program is free software; you can redistribute it and/or modify
00006 #  it under the terms of the GNU General Public License as published by
00007 #  the Free Software Foundation; either version 2 of the License, or
00008 #  (at your option) any later version.
00009 #
00010 #  This program is distributed in the hope that it will be useful,
00011 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 #  GNU General Public License for more details.
00014 #
00015 #  You should have received a copy of the GNU General Public License
00016 #  along with this program; if not, write to the Free Software
00017 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 #
00019 """
00020 """
00021 
00022 __author__ = 'Christian Heimes <tiran@cheimes.de>'
00023 __docformat__ = 'restructuredtext'
00024 
00025 from Testing import ZopeTestCase # side effect import. leave it here.
00026 from Products.ATContentTypes.tests import atcttestcase, atctftestcase
00027 
00028 import transaction
00029 from Products.CMFCore.permissions import View
00030 from Products.CMFCore.permissions import ModifyPortalContent
00031 from Products.Archetypes.interfaces.layer import ILayerContainer
00032 from Products.Archetypes.atapi import *
00033 from Products.ATContentTypes.tests.utils import dcEdit
00034 
00035 from Products.ATContentTypes.content.event import ATEvent
00036 from Products.ATContentTypes.tests.utils import EmptyValidator
00037 from Products.ATContentTypes.tests.utils import EmailValidator
00038 from Products.ATContentTypes.tests.utils import URLValidator
00039 from Products.ATContentTypes.tests.utils import NotRequiredTidyHTMLValidator
00040 from Products.ATContentTypes.permission import ChangeEvents
00041 from Products.ATContentTypes.utils import DT2dt
00042 from DateTime import DateTime
00043 from Products.ATContentTypes.interfaces import ICalendarSupport
00044 from Products.ATContentTypes.interfaces import IATEvent
00045 from Interface.Verify import verifyObject
00046 
00047 # z3 imports
00048 from Products.ATContentTypes.interface import ICalendarSupport as Z3ICalendarSupport
00049 from Products.ATContentTypes.interface import IATEvent as Z3IATEvent
00050 from zope.interface.verify import verifyObject as Z3verifyObject
00051 
00052 
00053 LOCATION = 'my location'
00054 EV_TYPE  = 'Meeting'
00055 EV_URL   = 'http://example.org/'
00056 S_DATE   = DateTime()
00057 E_DATE   = DateTime()+1
00058 C_NAME   = 'John Doe'
00059 C_PHONE  = '+1212356789'
00060 C_EMAIL  = 'john@example.org'
00061 EV_ATTENDEES = ('john@doe.com',
00062                 'john@doe.org',
00063                 'john@example.org')
00064 TEXT = "lorem ipsum"
00065 
00066 def editATCT(obj):
00067     dcEdit(obj)
00068     obj.setLocation(LOCATION)
00069     obj.setEventType(EV_TYPE)
00070     obj.setEventUrl(EV_URL)
00071     obj.setStartDate(S_DATE)
00072     obj.setEndDate(E_DATE)
00073     obj.setContactName(C_NAME)
00074     obj.setContactPhone(C_PHONE)
00075     obj.setContactEmail(C_EMAIL)
00076     obj.setAttendees(EV_ATTENDEES)
00077     obj.setText(TEXT)
00078 
00079 
00080 tests = []
00081 
00082 class TestSiteATEvent(atcttestcase.ATCTTypeTestCase):
00083 
00084     klass = ATEvent
00085     portal_type = 'Event'
00086     title = 'Event'
00087     meta_type = 'ATEvent'
00088     icon = 'event_icon.gif'
00089 
00090     def test_doesImplementCalendarSupport(self):
00091         self.failUnless(ICalendarSupport.isImplementedBy(self._ATCT))
00092         self.failUnless(verifyObject(ICalendarSupport, self._ATCT))
00093 
00094     def test_doesImplementZ3CalendarSupport(self):
00095         iface = Z3ICalendarSupport
00096         self.failUnless(Z3verifyObject(iface, self._ATCT))
00097 
00098     def test_implementsATEvent(self):
00099         iface = IATEvent
00100         self.failUnless(iface.isImplementedBy(self._ATCT))
00101         self.failUnless(verifyObject(iface, self._ATCT))
00102 
00103     def test_implementsZ3ATEvent(self):
00104         iface = Z3IATEvent
00105         self.failUnless(Z3verifyObject(iface, self._ATCT))
00106 
00107     def test_edit(self):
00108         new = self._ATCT
00109         editATCT(new)
00110         self.assertEquals(new.start_date, DT2dt(new.start()))
00111         self.assertEquals(new.end_date, DT2dt(new.end()))
00112         self.assertEquals(new.start_date, DT2dt(S_DATE))
00113         self.assertEquals(new.end_date, DT2dt(E_DATE))
00114         self.assertEquals(new.duration, new.end_date - new.start_date)
00115 
00116     def test_cmp(self):
00117         e1 = self._ATCT
00118         e2 = self._createType(self.folder, self.portal_type, 'e2')
00119         day29 = DateTime('2004-12-29 0:00:00')
00120         day30 = DateTime('2004-12-30 0:00:00')
00121         day31 = DateTime('2004-12-31 0:00:00')
00122 
00123         e1.edit(startDate = day29, endDate=day30, title='event')
00124         e2.edit(startDate = day29, endDate=day30, title='event')
00125         self.failUnlessEqual(cmp(e1, e2), 0)
00126 
00127         # start date
00128         e1.edit(startDate = day29, endDate=day30, title='event')
00129         e2.edit(startDate = day30, endDate=day31, title='event')
00130         self.failUnlessEqual(cmp(e1, e2), -1) # e1 < e2
00131 
00132         # duration
00133         e1.edit(startDate = day29, endDate=day30, title='event')
00134         e2.edit(startDate = day29, endDate=day31, title='event')
00135         self.failUnlessEqual(cmp(e1, e2), -1)  # e1 < e2
00136 
00137         # title
00138         e1.edit(startDate = day29, endDate=day30, title='event')
00139         e2.edit(startDate = day29, endDate=day30, title='evenz')
00140         self.failUnlessEqual(cmp(e1, e2), -1)  # e1 < e2
00141 
00142     def test_ical(self):
00143         event = self._ATCT
00144         event.setStartDate(DateTime('2001/01/01 12:00:00 GMT+1'))
00145         event.setEndDate(DateTime('2001/01/01 14:00:00 GMT+1'))
00146         event.setTitle('cool event')
00147         ical = event.getICal()
00148         lines = ical.split('\n')
00149         self.assertEqual(lines[0], "BEGIN:VEVENT")
00150         self.assertEqual(lines[5], "SUMMARY:%s"%event.Title())
00151         # times should be converted to UTC
00152         self.assertEqual(lines[6], "DTSTART:20010101T110000Z")
00153         self.assertEqual(lines[7], "DTEND:20010101T130000Z")
00154 
00155     def test_vcal(self):
00156         event = self._ATCT
00157         event.setStartDate(DateTime('2001/01/01 12:00:00 GMT+1'))
00158         event.setEndDate(DateTime('2001/01/01 14:00:00 GMT+1'))
00159         event.setTitle('cool event')
00160         vcal = event.getVCal()
00161         lines = vcal.split('\n')
00162         self.assertEqual(lines[0], "BEGIN:VEVENT")
00163         self.assertEqual(lines[7], "SUMMARY:%s"%event.Title())
00164         # times should be converted to UTC
00165         self.assertEqual(lines[1], "DTSTART:20010101T110000Z")
00166         self.assertEqual(lines[2], "DTEND:20010101T130000Z")
00167 
00168     def test_get_size(self):
00169         atct = self._ATCT
00170         editATCT(atct)
00171         self.failUnlessEqual(atct.get_size(), len(TEXT))
00172 
00173     def test_set_subject_sets_eventtype(self):
00174         atct = self._ATCT
00175         atct.setSubject(['a','b','c'])
00176         self.failUnless('a' in atct.getEventType())
00177         self.failUnless('b' in atct.getEventType())
00178         self.failUnless('c' in atct.getEventType())
00179 
00180 tests.append(TestSiteATEvent)
00181 
00182 class TestATEventFields(atcttestcase.ATCTFieldTestCase):
00183 
00184     def afterSetUp(self):
00185         atcttestcase.ATCTFieldTestCase.afterSetUp(self)
00186         self._dummy = self.createDummy(klass=ATEvent)
00187 
00188     def test_locationField(self):
00189         dummy = self._dummy
00190         field = dummy.getField('location')
00191 
00192         self.failUnless(ILayerContainer.isImplementedBy(field))
00193         self.failUnless(field.required == 0, 'Value is %s' % field.required)
00194         self.failUnless(field.default == '', 'Value is %s' % str(field.default))
00195         self.failUnless(field.searchable == 1, 'Value is %s' % field.searchable)
00196         self.failUnless(field.vocabulary == (),
00197                         'Value is %s' % str(field.vocabulary))
00198         self.failUnless(field.enforceVocabulary == 0,
00199                         'Value is %s' % field.enforceVocabulary)
00200         self.failUnless(field.multiValued == 0,
00201                         'Value is %s' % field.multiValued)
00202         self.failUnless(field.isMetadata == 0, 'Value is %s' % field.isMetadata)
00203         self.failUnless(field.accessor == 'getLocation',
00204                         'Value is %s' % field.accessor)
00205         self.failUnless(field.mutator == 'setLocation',
00206                         'Value is %s' % field.mutator)
00207         self.failUnless(field.read_permission == View,
00208                         'Value is %s' % field.read_permission)
00209         self.failUnless(field.write_permission == ChangeEvents,
00210                         'Value is %s' % field.write_permission)
00211         self.failUnless(field.generateMode == 'veVc',
00212                         'Value is %s' % field.generateMode)
00213         self.failUnless(field.force == '', 'Value is %s' % field.force)
00214         self.failUnless(field.type == 'string', 'Value is %s' % field.type)
00215         self.failUnless(isinstance(field.storage, AttributeStorage),
00216                         'Value is %s' % type(field.storage))
00217         self.failUnless(field.getLayerImpl('storage') == AttributeStorage(),
00218                         'Value is %s' % field.getLayerImpl('storage'))
00219         self.failUnless(ILayerContainer.isImplementedBy(field))
00220         self.failUnless(field.validators == EmptyValidator,
00221                         'Value is %s' % str(field.validators))
00222         self.failUnless(isinstance(field.widget, StringWidget),
00223                         'Value is %s' % id(field.widget))
00224         vocab = field.Vocabulary(dummy)
00225         self.failUnless(isinstance(vocab, DisplayList),
00226                         'Value is %s' % type(vocab))
00227         self.failUnless(tuple(vocab) == (), 'Value is %s' % str(tuple(vocab)))
00228 
00229     def test_eventTypeField(self):
00230         dummy = self._dummy
00231         field = dummy.getField('eventType')
00232         self.failUnless(ILayerContainer.isImplementedBy(field))
00233         self.failUnless(field.required == 0, 'Value is %s' % field.required)
00234         self.failUnless(field.default == (), 'Value is %s' % str(str(field.default)))
00235         self.failUnless(field.searchable == 1, 'Value is %s' % field.searchable)
00236         self.failUnless(field.enforceVocabulary == 0,
00237                         'Value is %s' % field.enforceVocabulary)
00238         self.failUnless(field.multiValued == 0,
00239                         'Value is %s' % field.multiValued)
00240         self.failUnless(field.isMetadata == 0, 'Value is %s' % field.isMetadata)
00241         self.failUnless(field.accessor == 'getEventType',
00242                         'Value is %s' % field.accessor)
00243         self.failUnless(field.mutator == 'setEventType',
00244                         'Value is %s' % field.mutator)
00245         self.failUnless(field.read_permission == View,
00246                         'Value is %s' % field.read_permission)
00247         self.failUnless(field.write_permission ==
00248                         ChangeEvents,
00249                         'Value is %s' % field.write_permission)
00250         self.failUnless(field.generateMode == 'veVc',
00251                         'Value is %s' % field.generateMode)
00252         self.failUnless(field.force == '', 'Value is %s' % field.force)
00253         self.failUnless(field.type == 'lines', 'Value is %s' % field.type)
00254         self.failUnless(isinstance(field.storage, AttributeStorage),
00255                         'Value is %s' % type(field.storage))
00256         self.failUnless(field.getLayerImpl('storage') == AttributeStorage(),
00257                         'Value is %s' % field.getLayerImpl('storage'))
00258         self.failUnless(ILayerContainer.isImplementedBy(field))
00259         self.failUnless(field.validators == EmptyValidator,
00260                         'Value is %s' % repr(field.validators))
00261         self.failUnless(isinstance(field.widget, KeywordWidget),
00262                         'Value is %s' % id(field.widget))
00263 
00264 
00265     def test_eventUrlField(self):
00266         dummy = self._dummy
00267         field = dummy.getField('eventUrl')
00268 
00269         self.failUnless(ILayerContainer.isImplementedBy(field))
00270         self.failUnless(field.required == 0, 'Value is %s' % field.required)
00271         self.failUnless(field.default == '', 'Value is %s' % str(field.default))
00272         self.failUnless(field.searchable == 1, 'Value is %s' % field.searchable)
00273         self.failUnless(field.vocabulary == (),
00274                         'Value is %s' % str(field.vocabulary))
00275         self.failUnless(field.enforceVocabulary == 0,
00276                         'Value is %s' % field.enforceVocabulary)
00277         self.failUnless(field.multiValued == 0,
00278                         'Value is %s' % field.multiValued)
00279         self.failUnless(field.isMetadata == 0, 'Value is %s' % field.isMetadata)
00280         self.failUnless(field.accessor == 'event_url',
00281                         'Value is %s' % field.accessor)
00282         self.failUnless(field.mutator == 'setEventUrl',
00283                         'Value is %s' % field.mutator)
00284         self.failUnless(field.read_permission == View,
00285                         'Value is %s' % field.read_permission)
00286         self.failUnless(field.write_permission ==
00287                         ChangeEvents,
00288                         'Value is %s' % field.write_permission)
00289         self.failUnless(field.generateMode == 'veVc',
00290                         'Value is %s' % field.generateMode)
00291         self.failUnless(field.force == '', 'Value is %s' % field.force)
00292         self.failUnless(field.type == 'string', 'Value is %s' % field.type)
00293         self.failUnless(isinstance(field.storage, AttributeStorage),
00294                         'Value is %s' % type(field.storage))
00295         self.failUnless(field.getLayerImpl('storage') == AttributeStorage(),
00296                         'Value is %s' % field.getLayerImpl('storage'))
00297         self.failUnless(ILayerContainer.isImplementedBy(field))
00298         self.failUnlessEqual(field.validators, URLValidator)
00299         self.failUnless(isinstance(field.widget, StringWidget),
00300                         'Value is %s' % id(field.widget))
00301         vocab = field.Vocabulary(dummy)
00302         self.failUnless(isinstance(vocab, DisplayList),
00303                         'Value is %s' % type(vocab))
00304         self.failUnless(tuple(vocab) == (), 'Value is %s' % str(tuple(vocab)))
00305 
00306     def test_startDateField(self):
00307         dummy = self._dummy
00308         field = dummy.getField('startDate')
00309 
00310         self.failUnless(ILayerContainer.isImplementedBy(field))
00311         self.failUnless(field.required == 1, 'Value is %s' % field.required)
00312         self.failUnless(field.default == None , 'Value is %s' % str(field.default))
00313         self.failUnless(field.default_method == DateTime , 'Value is %s' % str(field.default_method))
00314         self.failUnless(field.searchable == False, 'Value is %s' % field.searchable)
00315         self.failUnless(field.vocabulary == (),
00316                         'Value is %s' % str(field.vocabulary))
00317         self.failUnless(field.enforceVocabulary == 0,
00318                         'Value is %s' % field.enforceVocabulary)
00319         self.failUnless(field.multiValued == 0,
00320                         'Value is %s' % field.multiValued)
00321         self.failUnless(field.isMetadata == 0, 'Value is %s' % field.isMetadata)
00322         self.failUnless(field.accessor == 'start',
00323                         'Value is %s' % field.accessor)
00324         self.failUnless(field.mutator == 'setStartDate',
00325                         'Value is %s' % field.mutator)
00326         self.failUnless(field.read_permission == View,
00327                         'Value is %s' % field.read_permission)
00328         self.failUnless(field.write_permission ==
00329                         ChangeEvents,
00330                         'Value is %s' % field.write_permission)
00331         self.failUnless(field.generateMode == 'veVc',
00332                         'Value is %s' % field.generateMode)
00333         self.failUnless(field.force == '', 'Value is %s' % field.force)
00334         self.failUnless(field.type == 'datetime', 'Value is %s' % field.type)
00335         self.failUnless(isinstance(field.storage, AttributeStorage),
00336                         'Value is %s' % type(field.storage))
00337         self.failUnless(field.getLayerImpl('storage') == AttributeStorage(),
00338                         'Value is %s' % field.getLayerImpl('storage'))
00339         self.failUnless(ILayerContainer.isImplementedBy(field))
00340         self.failUnless(field.validators == (),
00341                         'Value is %s' % str(field.validators))
00342         self.failUnless(isinstance(field.widget, CalendarWidget),
00343                         'Value is %s' % id(field.widget))
00344         vocab = field.Vocabulary(dummy)
00345         self.failUnless(isinstance(vocab, DisplayList),
00346                         'Value is %s' % type(vocab))
00347         self.failUnless(tuple(vocab) == (), 'Value is %s' % str(tuple(vocab)))
00348 
00349 
00350     def test_endDateField(self):
00351         dummy = self._dummy
00352         field = dummy.getField('endDate')
00353 
00354         self.failUnless(ILayerContainer.isImplementedBy(field))
00355         self.failUnless(field.required == 1, 'Value is %s' % field.required)
00356         self.failUnless(field.default == None , 'Value is %s' % str(field.default))
00357         self.failUnless(field.default_method == DateTime , 'Value is %s' % str(field.default_method))
00358         self.failUnless(field.searchable == False, 'Value is %s' % field.searchable)
00359         self.failUnless(field.vocabulary == (),
00360                         'Value is %s' % str(field.vocabulary))
00361         self.failUnless(field.enforceVocabulary == 0,
00362                         'Value is %s' % field.enforceVocabulary)
00363         self.failUnless(field.multiValued == 0,
00364                         'Value is %s' % field.multiValued)
00365         self.failUnless(field.isMetadata == 0, 'Value is %s' % field.isMetadata)
00366         self.failUnless(field.accessor == 'end',
00367                         'Value is %s' % field.accessor)
00368         self.failUnless(field.mutator == 'setEndDate',
00369                         'Value is %s' % field.mutator)
00370         self.failUnless(field.read_permission == View,
00371                         'Value is %s' % field.read_permission)
00372         self.failUnless(field.write_permission ==
00373                         ChangeEvents,
00374                         'Value is %s' % field.write_permission)
00375         self.failUnless(field.generateMode == 'veVc',
00376                         'Value is %s' % field.generateMode)
00377         self.failUnless(field.force == '', 'Value is %s' % field.force)
00378         self.failUnless(field.type == 'datetime', 'Value is %s' % field.type)
00379         self.failUnless(isinstance(field.storage, AttributeStorage),
00380                         'Value is %s' % type(field.storage))
00381         self.failUnless(field.getLayerImpl('storage') == AttributeStorage(),
00382                         'Value is %s' % field.getLayerImpl('storage'))
00383         self.failUnless(ILayerContainer.isImplementedBy(field))
00384         self.failUnless(field.validators == (),
00385                         'Value is %s' % str(field.validators))
00386         self.failUnless(isinstance(field.widget, CalendarWidget),
00387                         'Value is %s' % id(field.widget))
00388         vocab = field.Vocabulary(dummy)
00389         self.failUnless(isinstance(vocab, DisplayList),
00390                         'Value is %s' % type(vocab))
00391         self.failUnless(tuple(vocab) == (), 'Value is %s' % str(tuple(vocab)))
00392 
00393     def test_contactNameField(self):
00394         dummy = self._dummy
00395         field = dummy.getField('contactName')
00396 
00397         self.failUnless(ILayerContainer.isImplementedBy(field))
00398         self.failUnless(field.required == 0, 'Value is %s' % field.required)
00399         self.failUnless(field.default == '', 'Value is %s' % str(field.default))
00400         self.failUnless(field.searchable == 1, 'Value is %s' % field.searchable)
00401         self.failUnless(field.vocabulary == (),
00402                         'Value is %s' % str(field.vocabulary))
00403         self.failUnless(field.enforceVocabulary == 0,
00404                         'Value is %s' % field.enforceVocabulary)
00405         self.failUnless(field.multiValued == 0,
00406                         'Value is %s' % field.multiValued)
00407         self.failUnless(field.isMetadata == 0, 'Value is %s' % field.isMetadata)
00408         self.failUnless(field.accessor == 'contact_name',
00409                         'Value is %s' % field.accessor)
00410         self.failUnless(field.mutator == 'setContactName',
00411                         'Value is %s' % field.mutator)
00412         self.failUnless(field.read_permission == View,
00413                         'Value is %s' % field.read_permission)
00414         self.failUnless(field.write_permission ==
00415                         ChangeEvents,
00416                         'Value is %s' % field.write_permission)
00417         self.failUnless(field.generateMode == 'veVc',
00418                         'Value is %s' % field.generateMode)
00419         self.failUnless(field.force == '', 'Value is %s' % field.force)
00420         self.failUnless(field.type == 'string', 'Value is %s' % field.type)
00421         self.failUnless(isinstance(field.storage, AttributeStorage),
00422                         'Value is %s' % type(field.storage))
00423         self.failUnless(field.getLayerImpl('storage') == AttributeStorage(),
00424                         'Value is %s' % field.getLayerImpl('storage'))
00425         self.failUnless(ILayerContainer.isImplementedBy(field))
00426         self.failUnless(field.validators == EmptyValidator,
00427                         'Value is %s' % str(field.validators))
00428         self.failUnless(isinstance(field.widget, StringWidget),
00429                         'Value is %s' % id(field.widget))
00430         vocab = field.Vocabulary(dummy)
00431         self.failUnless(isinstance(vocab, DisplayList),
00432                         'Value is %s' % type(vocab))
00433         self.failUnless(tuple(vocab) == (), 'Value is %s' % str(tuple(vocab)))
00434 
00435     def test_contactEmailField(self):
00436         dummy = self._dummy
00437         field = dummy.getField('contactEmail')
00438 
00439         self.failUnless(ILayerContainer.isImplementedBy(field))
00440         self.failUnless(field.required == 0, 'Value is %s' % field.required)
00441         self.failUnless(field.default == '', 'Value is %s' % str(field.default))
00442         self.failUnless(field.searchable == 1, 'Value is %s' % field.searchable)
00443         self.failUnless(field.vocabulary == (),
00444                         'Value is %s' % str(field.vocabulary))
00445         self.failUnless(field.enforceVocabulary == 0,
00446                         'Value is %s' % field.enforceVocabulary)
00447         self.failUnless(field.multiValued == 0,
00448                         'Value is %s' % field.multiValued)
00449         self.failUnless(field.isMetadata == 0, 'Value is %s' % field.isMetadata)
00450         self.failUnless(field.accessor == 'contact_email',
00451                         'Value is %s' % field.accessor)
00452         self.failUnless(field.mutator == 'setContactEmail',
00453                         'Value is %s' % field.mutator)
00454         self.failUnless(field.read_permission == View,
00455                         'Value is %s' % field.read_permission)
00456         self.failUnless(field.write_permission ==
00457                         ChangeEvents,
00458                         'Value is %s' % field.write_permission)
00459         self.failUnless(field.generateMode == 'veVc',
00460                         'Value is %s' % field.generateMode)
00461         self.failUnless(field.force == '', 'Value is %s' % field.force)
00462         self.failUnless(field.type == 'string', 'Value is %s' % field.type)
00463         self.failUnless(isinstance(field.storage, AttributeStorage),
00464                         'Value is %s' % type(field.storage))
00465         self.failUnless(field.getLayerImpl('storage') == AttributeStorage(),
00466                         'Value is %s' % field.getLayerImpl('storage'))
00467         self.failUnless(ILayerContainer.isImplementedBy(field))
00468         self.failUnless(field.validators == EmailValidator,
00469                         'Value is %s' % str(field.validators))
00470         self.failUnless(isinstance(field.widget, StringWidget),
00471                         'Value is %s' % id(field.widget))
00472         vocab = field.Vocabulary(dummy)
00473         self.failUnless(isinstance(vocab, DisplayList),
00474                         'Value is %s' % type(vocab))
00475         self.failUnless(tuple(vocab) == (), 'Value is %s' % str(tuple(vocab)))
00476 
00477     def test_contactPhoneField(self):
00478         dummy = self._dummy
00479         field = dummy.getField('contactPhone')
00480 
00481         self.failUnless(ILayerContainer.isImplementedBy(field))
00482         self.failUnless(field.required == 0, 'Value is %s' % field.required)
00483         self.failUnless(field.default == '', 'Value is %s' % str(field.default))
00484         self.failUnless(field.searchable == 1, 'Value is %s' % field.searchable)
00485         self.failUnless(field.vocabulary == (),
00486                         'Value is %s' % str(field.vocabulary))
00487         self.failUnless(field.enforceVocabulary == 0,
00488                         'Value is %s' % field.enforceVocabulary)
00489         self.failUnless(field.multiValued == 0,
00490                         'Value is %s' % field.multiValued)
00491         self.failUnless(field.isMetadata == 0, 'Value is %s' % field.isMetadata)
00492         self.failUnless(field.accessor == 'contact_phone',
00493                         'Value is %s' % field.accessor)
00494         self.failUnless(field.mutator == 'setContactPhone',
00495                         'Value is %s' % field.mutator)
00496         self.failUnless(field.read_permission == View,
00497                         'Value is %s' % field.read_permission)
00498         self.failUnless(field.write_permission ==
00499                         ChangeEvents,
00500                         'Value is %s' % field.write_permission)
00501         self.failUnless(field.generateMode == 'veVc',
00502                         'Value is %s' % field.generateMode)
00503         self.failUnless(field.force == '', 'Value is %s' % field.force)
00504         self.failUnless(field.type == 'string', 'Value is %s' % field.type)
00505         self.failUnless(isinstance(field.storage, AttributeStorage),
00506                         'Value is %s' % type(field.storage))
00507         self.failUnless(field.getLayerImpl('storage') == AttributeStorage(),
00508                         'Value is %s' % field.getLayerImpl('storage'))
00509         self.failUnless(ILayerContainer.isImplementedBy(field))
00510         self.failUnlessEqual(field.validators, EmptyValidator)
00511         self.failUnless(isinstance(field.widget, StringWidget),
00512                         'Value is %s' % id(field.widget))
00513         vocab = field.Vocabulary(dummy)
00514         self.failUnless(isinstance(vocab, DisplayList),
00515                         'Value is %s' % type(vocab))
00516         self.failUnless(tuple(vocab) == (), 'Value is %s' % str(tuple(vocab)))
00517 
00518     def test_attendeesField(self):
00519         dummy = self._dummy
00520         field = dummy.getField('attendees')
00521 
00522         self.failUnless(ILayerContainer.isImplementedBy(field))
00523         self.failUnless(field.required == 0, 'Value is %s' % field.required)
00524         self.failUnless(field.default == (), 'Value is %s' % str(field.default))
00525         self.failUnless(field.searchable == 1, 'Value is %s' % field.searchable)
00526         self.failUnless(field.vocabulary == (),
00527                         'Value is %s' % str(field.vocabulary))
00528         self.failUnless(field.enforceVocabulary == 0,
00529                         'Value is %s' % field.enforceVocabulary)
00530         self.failUnless(field.multiValued == 0,
00531                         'Value is %s' % field.multiValued)
00532         self.failUnless(field.isMetadata == 0, 'Value is %s' % field.isMetadata)
00533         self.failUnless(field.accessor == 'getAttendees',
00534                         'Value is %s' % field.accessor)
00535         self.failUnless(field.mutator == 'setAttendees',
00536                         'Value is %s' % field.mutator)
00537         self.failUnless(field.read_permission == View,
00538                         'Value is %s' % field.read_permission)
00539         self.failUnless(field.write_permission ==
00540                         ChangeEvents,
00541                         'Value is %s' % field.write_permission)
00542         self.failUnless(field.generateMode == 'veVc',
00543                         'Value is %s' % field.generateMode)
00544         self.failUnless(field.force == '', 'Value is %s' % field.force)
00545         self.failUnless(field.type == 'lines', 'Value is %s' % field.type)
00546         self.failUnless(isinstance(field.storage, AttributeStorage),
00547                         'Value is %s' % type(field.storage))
00548         self.failUnless(field.getLayerImpl('storage') == AttributeStorage(),
00549                         'Value is %s' % field.getLayerImpl('storage'))
00550         self.failUnless(ILayerContainer.isImplementedBy(field))
00551         self.failUnless(isinstance(field.widget, LinesWidget),
00552                         'Value is %s' % id(field.widget))
00553         vocab = field.Vocabulary(dummy)
00554         self.failUnless(isinstance(vocab, DisplayList),
00555                         'Value is %s' % type(vocab))
00556         self.failUnless(tuple(vocab) == (), 'Value is %s' % str(tuple(vocab)))
00557 
00558     def test_textField(self):
00559         dummy = self._dummy
00560         field = dummy.getField('text')
00561 
00562         self.failUnless(ILayerContainer.isImplementedBy(field))
00563         self.failUnless(field.required == 0, 'Value is %s' % field.required)
00564         self.failUnless(field.default == '', 'Value is %s' % str(field.default))
00565         self.failUnless(field.searchable == 1, 'Value is %s' % field.searchable)
00566         self.failUnless(field.vocabulary == (),
00567                         'Value is %s' % str(field.vocabulary))
00568         self.failUnless(field.enforceVocabulary == 0,
00569                         'Value is %s' % field.enforceVocabulary)
00570         self.failUnless(field.multiValued == 0,
00571                         'Value is %s' % field.multiValued)
00572         self.failUnless(field.isMetadata == 0, 'Value is %s' % field.isMetadata)
00573         self.failUnless(field.accessor == 'getText',
00574                         'Value is %s' % field.accessor)
00575         self.failUnless(field.mutator == 'setText',
00576                         'Value is %s' % field.mutator)
00577         self.failUnless(field.read_permission == View,
00578                         'Value is %s' % field.read_permission)
00579         self.failUnless(field.write_permission ==
00580                         ModifyPortalContent,
00581                         'Value is %s' % field.write_permission)
00582         self.failUnless(field.generateMode == 'veVc',
00583                         'Value is %s' % field.generateMode)
00584         self.failUnless(field.force == '', 'Value is %s' % field.force)
00585         self.failUnless(field.type == 'text', 'Value is %s' % field.type)
00586         self.failUnless(isinstance(field.storage, AnnotationStorage),
00587                         'Value is %s' % type(field.storage))
00588         self.failUnless(field.getLayerImpl('storage') == AnnotationStorage(migrate=True),
00589                         'Value is %s' % field.getLayerImpl('storage'))
00590         self.failUnless(ILayerContainer.isImplementedBy(field))
00591         self.failUnless(field.validators == NotRequiredTidyHTMLValidator,
00592                         'Value is %s' % repr(field.validators))
00593         self.failUnless(isinstance(field.widget, RichWidget),
00594                         'Value is %s' % id(field.widget))
00595         vocab = field.Vocabulary(dummy)
00596         self.failUnless(isinstance(vocab, DisplayList),
00597                         'Value is %s' % type(vocab))
00598         self.failUnless(tuple(vocab) == (), 'Value is %s' % str(tuple(vocab)))
00599 
00600         self.failUnless(field.primary == 1, 'Value is %s' % field.primary)
00601         self.failUnless(field.default_content_type is None,
00602                         'Value is %s' % field.default_content_type)
00603         self.failUnless(field.default_output_type == 'text/x-html-safe',
00604                         'Value is %s' % field.default_output_type)
00605         self.failUnless('text/html' in field.getAllowedContentTypes(dummy))
00606 
00607     def beforeTearDown(self):
00608         # more
00609         atcttestcase.ATCTFieldTestCase.beforeTearDown(self)
00610 
00611 tests.append(TestATEventFields)
00612 
00613 class TestATEventFunctional(atctftestcase.ATCTIntegrationTestCase):
00614 
00615     portal_type = 'Event'
00616     views = ('event_view', 'vcs_view', 'ics_view', )
00617 
00618 tests.append(TestATEventFunctional)
00619 
00620 import unittest
00621 def test_suite():
00622     suite = unittest.TestSuite()
00623     for test in tests:
00624         suite.addTest(unittest.makeSuite(test))
00625     return suite