Back to index

plone3  3.1.7
Public Member Functions | Private Attributes
Archetypes.tests.test_metadata.ExtensibleMetadataTest Class Reference
Inheritance diagram for Archetypes.tests.test_metadata.ExtensibleMetadataTest:
Inheritance graph
[legend]
Collaboration diagram for Archetypes.tests.test_metadata.ExtensibleMetadataTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def makeDummy
def testAccessors
def testMutators
def testMetaFields

Private Attributes

 _dummy

Detailed Description

Definition at line 117 of file test_metadata.py.


Member Function Documentation

Definition at line 119 of file test_metadata.py.

00119 
00120     def afterSetUp(self):
00121         ATSiteTestCase.afterSetUp(self)
00122         self._dummy = mkDummyInContext(klass=Dummy, oid='dummy',
00123                                        context=self.portal, schema=schema)
00124         # to enable overrideDiscussionFor
00125         self.setRoles(['Manager'])
00126         self.makeDummy()
00127         addMetadataTo(self._dummy)

Definition at line 128 of file test_metadata.py.

00128 
00129     def makeDummy(self):
00130         return self._dummy

Definition at line 131 of file test_metadata.py.

00131 
00132     def testAccessors(self):
00133         obj = self._dummy
00134         for field in fieldList:
00135             accessor = field[0]
00136             fobj = getattr(obj, accessor, None)
00137             if not fobj:
00138                 self.fail('Missing accessor for field: %s' % str(field))
00139             self.failUnless(hasattr(obj, accessor),
00140                             'Missing accessor %s' % accessor)
00141             self.failUnless((type(fobj) is FunctionType or
00142                              hasattr(fobj, '__call__')),
00143                             'Accessor %s is not callable' % accessor)

Here is the call graph for this function:

Definition at line 156 of file test_metadata.py.

00156 
00157     def testMetaFields(self):
00158         obj = self._dummy
00159         for field in fieldList:
00160             meta = field[2]
00161             if not meta: continue
00162             md = aq_base(obj)._md
00163             field = aq_base(obj).Schema()[meta]
00164             self.failUnless(md.has_key(meta), 'Missing field %s' % meta)
00165             _marker = []
00166             value = md.get(meta, _marker)
00167             # We are checking here if the metadata
00168             # for a given field has been correctly initialized.
00169             self.failIf(value is _marker,
00170                         'Metadata field %s has not been correctly '
00171                         'initialized.' % meta)
00172             self.failUnless(field.isMetadata,
00173                             'isMetadata not set correctly for field %s.' % meta)
00174 

Definition at line 144 of file test_metadata.py.

00144 
00145     def testMutators(self):
00146         obj = self._dummy
00147         for field in fieldList:
00148             mutator = field[1]
00149             if not mutator: continue
00150             fobj = getattr(obj, mutator, None)
00151             self.failUnless(hasattr(obj, mutator),
00152                             'Missing mutator %s' % mutator)
00153             self.failUnless((type(fobj) is FunctionType
00154                              or hasattr(fobj, '__call__')),
00155                             'Mutator %s is not callable' % mutator)


Member Data Documentation

Definition at line 121 of file test_metadata.py.


The documentation for this class was generated from the following file: