Back to index

plone3  3.1.7
Public Member Functions | Private Member Functions
GenericSetup.tests.test_content.SimpleINIAwareTests Class Reference
Inheritance diagram for GenericSetup.tests.test_content.SimpleINIAwareTests:
Inheritance graph
[legend]
Collaboration diagram for GenericSetup.tests.test_content.SimpleINIAwareTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_as_ini_no_properties
def test_as_ini_string_property
def test_as_ini_other_properties
def test_put_ini_empty
def test_put_ini_with_values_stripped
def test_put_ini_other_properties

Private Member Functions

def _getTargetClass

Detailed Description

Definition at line 37 of file test_content.py.


Member Function Documentation

Definition at line 39 of file test_content.py.

00039 
00040     def _getTargetClass(self):
00041         from Products.GenericSetup.content import SimpleINIAware
00042         return SimpleINIAware

Definition at line 43 of file test_content.py.

00043 
00044     def test_as_ini_no_properties(self):
00045         context = _makePropertied('no_properties')
00046         context._properties = ()
00047         adapter = self._getTargetClass()(context)
00048         text = adapter.as_ini()
00049         parser = ConfigParser()
00050         parser.readfp(StringIO(text))
00051         self.failIf(parser.sections())
00052         default_options = parser.defaults()
00053         self.assertEqual(len(default_options), 0)

Definition at line 70 of file test_content.py.

00070 
00071     def test_as_ini_other_properties(self):
00072         from DateTime.DateTime import DateTime
00073         INTPROP = 42
00074         FLOATPROP = 3.1415926
00075         DATESTR = '2005-11-07T12:00:00.000Z'
00076         context = _makePropertied('string_property')
00077         context._properties = ()
00078         context._setProperty('int_prop', INTPROP, 'int')
00079         context._setProperty('float_prop', FLOATPROP, 'float')
00080         context._setProperty('date_prop', DateTime(DATESTR), 'date')
00081         adapter = self._getTargetClass()(context)
00082         text = adapter.as_ini()
00083         parser = ConfigParser()
00084         parser.readfp(StringIO(text))
00085         self.failIf(parser.sections())
00086         default_options = parser.defaults()
00087         self.assertEqual(len(default_options), 3)
00088         self.assertEqual(default_options['int_prop'], str(INTPROP))
00089         self.assertEqual(default_options['float_prop'], str(FLOATPROP))
00090         self.assertEqual(default_options['date_prop'], str(DateTime(DATESTR)))

Definition at line 54 of file test_content.py.

00054 
00055     def test_as_ini_string_property(self):
00056         TITLE = 'String Property'
00057         DESCR = 'Another property'
00058         context = _makePropertied('string_property')
00059         context.title = TITLE
00060         context._setProperty('description', DESCR)
00061         adapter = self._getTargetClass()(context)
00062         text = adapter.as_ini()
00063         parser = ConfigParser()
00064         parser.readfp(StringIO(text))
00065         self.failIf(parser.sections())
00066         default_options = parser.defaults()
00067         self.assertEqual(len(default_options), 2)
00068         self.assertEqual(default_options['title'].strip(), TITLE)
00069         self.assertEqual(default_options['description'].strip(), DESCR)

Definition at line 91 of file test_content.py.

00091 
00092     def test_put_ini_empty(self):
00093         context = _makePropertied('empty_ini')
00094         adapter = self._getTargetClass()(context)
00095         context._properties = ()
00096         self.failIf(context.propertyItems())
00097         adapter.put_ini('')
00098         self.failIf(context.propertyItems())

Definition at line 110 of file test_content.py.

00110 
00111     def test_put_ini_other_properties(self):
00112         from DateTime.DateTime import DateTime
00113         INTPROP = 42
00114         FLOATPROP = 3.1415926
00115         DATESTR = '2005-11-07T12:00:00.000Z'
00116         DATESTR2 = '2005-11-09T12:00:00.000Z'
00117         context = _makePropertied('string_property')
00118         context._properties = ()
00119         context._setProperty('int_prop', INTPROP, 'int')
00120         context._setProperty('float_prop', FLOATPROP, 'float')
00121         context._setProperty('date_prop', DateTime(DATESTR), 'date')
00122         adapter = self._getTargetClass()(context)
00123         adapter.put_ini('''\
00124 [DEFAULT]
00125 int_prop = 13 
00126 \nfloat_prop = 2.818
00127 \ndate_prop = %s''' % DATESTR2)
00128         self.assertEqual(len(context.propertyIds()), 3)
00129         self.assertEqual(context.int_prop, 13)
00130         self.assertEqual(context.float_prop, 2.818)
00131         self.assertEqual(context.date_prop, DateTime(DATESTR2))
00132 

Definition at line 99 of file test_content.py.

00099 
00100     def test_put_ini_with_values_stripped(self):
00101         context = _makePropertied('empty_ini')
00102         adapter = self._getTargetClass()(context)
00103         adapter.put_ini('[DEFAULT]\ntitle = Foo \ndescription = bar ')
00104         props = context.propdict()
00105         self.assertEqual(len(props), 2)
00106         self.failUnless('title' in props)
00107         self.failUnless('description' in props)
00108         self.assertEqual(context.title, 'Foo')
00109         self.assertEqual(context.description, 'bar')


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