Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Private Member Functions
GenericSetup.tests.test_utils.PropertyManagerHelpersTests Class Reference

List of all members.

Public Member Functions

def setUp
def test__extractProperties_empty
def test__extractProperties_normal
def test__purgeProperties
def test__initProperties_normal
def test__initProperties_fixed
def test__initProperties_special
def test__initProperties_i18n
def test__initProperties_nopurge_base
def test__initProperties_nopurge_extension

Public Attributes

 helpers

Private Member Functions

def _getTargetClass
def _makeOne
def _populate

Detailed Description

Definition at line 247 of file test_utils.py.


Member Function Documentation

Definition at line 249 of file test_utils.py.

00249 
00250     def _getTargetClass(self):
00251         from Products.GenericSetup.utils import PropertyManagerHelpers
00252 
00253         return PropertyManagerHelpers

def GenericSetup.tests.test_utils.PropertyManagerHelpersTests._makeOne (   self,
  args,
  kw 
) [private]

Definition at line 254 of file test_utils.py.

00254 
00255     def _makeOne(self, *args, **kw):
00256         from Products.GenericSetup.utils import NodeAdapterBase
00257 
00258         class Foo(self._getTargetClass(), NodeAdapterBase):
00259 
00260             pass
00261 
00262         return Foo(*args, **kw)

Definition at line 292 of file test_utils.py.

00292 
00293     def _populate(self, obj):
00294         obj._updateProperty('foo_boolean', 'True')
00295         obj._updateProperty('foo_date', '2000/01/01')
00296         obj._updateProperty('foo_float', '1.1')
00297         obj._updateProperty('foo_int', '1')
00298         obj._updateProperty('foo_lines', 'Foo\nLines')
00299         obj._updateProperty('foo_long', '1')
00300         obj._updateProperty('foo_string', 'Foo String')
00301         obj._updateProperty('foo_text', 'Foo\nText')
00302         obj._updateProperty( 'foo_tokens', ('Foo', 'Tokens') )
00303         obj._updateProperty('foo_selection', 'Foo')
00304         obj._updateProperty( 'foo_mselection', ('Foo', 'Baz') )
00305         obj.foo_boolean0 = 0
00306         obj._updateProperty('foo_ro', 'RO')
00307         obj._updateProperty('foo_int_nodel', '1789')
00308         obj._updateProperty('foo_float_nodel', '3.1415')
00309         obj._updateProperty('foo_boolean_nodel', 'True')

Here is the caller graph for this function:

Definition at line 263 of file test_utils.py.

00263 
00264     def setUp(self):
00265         from OFS.PropertyManager import PropertyManager
00266 
00267         obj = PropertyManager('obj')
00268         obj.foobarbaz = ('Foo', 'Bar', 'Baz')
00269         obj._properties = ()
00270         obj.manage_addProperty('foo_boolean', '', 'boolean')
00271         obj.manage_addProperty('foo_date', '1970/01/01', 'date')
00272         obj.manage_addProperty('foo_float', '0', 'float')
00273         obj.manage_addProperty('foo_int', '0', 'int')
00274         obj.manage_addProperty('foo_lines', '', 'lines')
00275         obj.manage_addProperty('foo_long', '0', 'long')
00276         obj.manage_addProperty('foo_string', '', 'string')
00277         obj.manage_addProperty('foo_text', '', 'text')
00278         obj.manage_addProperty('foo_tokens', '', 'tokens')
00279         obj.manage_addProperty('foo_selection', 'foobarbaz', 'selection')
00280         obj.manage_addProperty('foo_mselection', 'foobarbaz',
00281                                'multiple selection')
00282         obj.manage_addProperty('foo_boolean0', '', 'boolean')
00283         obj.manage_addProperty('foo_ro', '', 'string')
00284         obj._properties[-1]['mode'] = '' # Read-only, not exported or purged
00285         obj.manage_addProperty('foo_int_nodel', 0, 'int')
00286         obj._properties[-1]['mode'] = 'w' # Not deletable
00287         obj.manage_addProperty('foo_float_nodel', 0, 'float')
00288         obj._properties[-1]['mode'] = 'w' # Not deletable
00289         obj.manage_addProperty('foo_boolean_nodel', '', 'boolean')
00290         obj._properties[-1]['mode'] = 'w' # Not deletable
00291         self.helpers = self._makeOne(obj, DummySetupEnviron())

Definition at line 310 of file test_utils.py.

00310 
00311     def test__extractProperties_empty(self):
00312         doc = self.helpers._doc = PrettyDocument()
00313         node = doc.createElement('dummy')
00314         node.appendChild(self.helpers._extractProperties())
00315         doc.appendChild(node)
00316 
00317         self.assertEqual(doc.toprettyxml(' '), _EMPTY_PROPERTY_EXPORT)

Definition at line 318 of file test_utils.py.

00318 
00319     def test__extractProperties_normal(self):
00320         self._populate(self.helpers.context)
00321         doc = self.helpers._doc = PrettyDocument()
00322         node = doc.createElement('dummy')
00323         node.appendChild(self.helpers._extractProperties())
00324         doc.appendChild(node)
00325 
00326         self.assertEqual(doc.toprettyxml(' '), _NORMAL_PROPERTY_EXPORT)

Here is the call graph for this function:

Definition at line 361 of file test_utils.py.

00361 
00362     def test__initProperties_fixed(self):
00363         node = parseString(_FIXED_PROPERTY_EXPORT).documentElement
00364         self.helpers._initProperties(node)
00365 
00366         doc = self.helpers._doc = PrettyDocument()
00367         node = doc.createElement('dummy')
00368         node.appendChild(self.helpers._extractProperties())
00369         doc.appendChild(node)
00370 
00371         self.assertEqual(doc.toprettyxml(' '), _NORMAL_PROPERTY_EXPORT)

Definition at line 383 of file test_utils.py.

00383 
00384     def test__initProperties_i18n(self):
00385         self.helpers.context.manage_addProperty('i18n_domain', '', 'string')
00386         node = parseString(_I18N_IMPORT).documentElement
00387         self.helpers._initProperties(node)
00388 
00389         self.assertEqual(self.helpers.context.i18n_domain, 'dummy_domain')

Definition at line 390 of file test_utils.py.

00390 
00391     def test__initProperties_nopurge_base(self):
00392         node = parseString(_NOPURGE_IMPORT).documentElement
00393         self.helpers.environ._should_purge = True # base profile
00394         obj = self.helpers.context
00395         obj._properties = ()
00396         obj.manage_addProperty('lines1', ('Foo', 'Gee'), 'lines')
00397         obj.manage_addProperty('lines2', ('Foo', 'Gee'), 'lines')
00398         obj.manage_addProperty('lines3', ('Foo', 'Gee'), 'lines')
00399         self.helpers._initProperties(node)
00400 
00401         self.assertEquals(obj.lines1, ('Foo', 'Bar'))
00402         self.assertEquals(obj.lines2, ('Foo', 'Bar'))
00403         self.assertEquals(obj.lines3, ('Gee', 'Foo', 'Bar'))

Definition at line 404 of file test_utils.py.

00404 
00405     def test__initProperties_nopurge_extension(self):
00406         node = parseString(_NOPURGE_IMPORT).documentElement
00407         self.helpers.environ._should_purge = False # extension profile
00408         obj = self.helpers.context
00409         obj._properties = ()
00410         obj.manage_addProperty('lines1', ('Foo', 'Gee'), 'lines')
00411         obj.manage_addProperty('lines2', ('Foo', 'Gee'), 'lines')
00412         obj.manage_addProperty('lines3', ('Foo', 'Gee'), 'lines')
00413         self.helpers._initProperties(node)
00414 
00415         self.assertEquals(obj.lines1, ('Foo', 'Bar'))
00416         self.assertEquals(obj.lines2, ('Foo', 'Bar'))
00417         self.assertEquals(obj.lines3, ('Gee', 'Foo', 'Bar'))
00418 

Definition at line 346 of file test_utils.py.

00346 
00347     def test__initProperties_normal(self):
00348         node = parseString(_NORMAL_PROPERTY_EXPORT).documentElement
00349         self.helpers._initProperties(node)
00350         self.assertEqual(type(self.helpers.context.foo_int), int)
00351         self.assertEqual(type(self.helpers.context.foo_string), str)
00352         self.assertEqual(type(self.helpers.context.foo_tokens), tuple)
00353         self.assertEqual(type(self.helpers.context.foo_tokens[0]), str)
00354 
00355         doc = self.helpers._doc = PrettyDocument()
00356         node = doc.createElement('dummy')
00357         node.appendChild(self.helpers._extractProperties())
00358         doc.appendChild(node)
00359 
00360         self.assertEqual(doc.toprettyxml(' '), _NORMAL_PROPERTY_EXPORT)

Definition at line 372 of file test_utils.py.

00372 
00373     def test__initProperties_special(self):
00374         node = parseString(_SPECIAL_IMPORT).documentElement
00375         self.helpers._initProperties(node)
00376 
00377         doc = self.helpers._doc = PrettyDocument()
00378         node = doc.createElement('dummy')
00379         node.appendChild(self.helpers._extractProperties())
00380         doc.appendChild(node)
00381 
00382         self.assertEqual(doc.toprettyxml(' '), _EMPTY_PROPERTY_EXPORT)

Definition at line 327 of file test_utils.py.

00327 
00328     def test__purgeProperties(self):
00329         obj = self.helpers.context
00330         self._populate(obj)
00331         self.helpers._purgeProperties()
00332 
00333         self.assertEqual(getattr(obj, 'foo_boolean', None), None)
00334         self.assertEqual(getattr(obj, 'foo_date', None), None)
00335         self.assertEqual(getattr(obj, 'foo_float', None), None)
00336         self.assertEqual(getattr(obj, 'foo_int', None), None)
00337         self.assertEqual(getattr(obj, 'foo_lines', None), None)
00338         self.assertEqual(getattr(obj, 'foo_long', None), None)
00339         self.assertEqual(getattr(obj, 'foo_string', None), None)
00340         self.assertEqual(getattr(obj, 'foo_text', None), None)
00341         self.assertEqual(getattr(obj, 'foo_tokens', None), None)
00342         self.assertEqual(getattr(obj, 'foo_selection', None), None)
00343         self.assertEqual(getattr(obj, 'foo_mselection', None), None)
00344         self.assertEqual(getattr(obj, 'foo_boolean0', None), None)
00345         self.assertEqual(getattr(obj, 'foo_ro', None), 'RO')

Here is the call graph for this function:


Member Data Documentation

Definition at line 290 of file test_utils.py.


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