Back to index

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

List of all members.

Public Member Functions

def afterSetUp
def test_availschemata
def test_nameschemata
def test_baseschemata
def test_metaschemata
def test_dupe_accessor_names_add
def test_dupe_edit_accessor_names_add
def test_dupe_mutator_names_add
def test_dupe_primary_add
def test_dupe_accessor_names_addField
def test_dupe_edit_accessor_names_addField
def test_dupe_mutator_names_addField
def test_dupe_primary_addField
def test_editableFields

Private Attributes

 _dummy

Detailed Description

Definition at line 46 of file test_schemata.py.


Member Function Documentation

Definition at line 48 of file test_schemata.py.

00048 
00049     def afterSetUp(self):
00050         registerType(Dummy, 'Archetypes')
00051         content_types, constructors, ftis = process_types(listTypes(), PKG_NAME)
00052         self._dummy = Dummy(oid='dummy')

Here is the call graph for this function:

Definition at line 53 of file test_schemata.py.

00053 
00054     def test_availschemata(self):
00055         dummy = self._dummy
00056         schemata = dummy.Schemata()
00057         keys = schemata.keys()
00058         keys.sort()
00059         self.assertEqual(keys, ['default', 'metadata'])

Definition at line 66 of file test_schemata.py.

00066 
00067     def test_baseschemata(self):
00068         dummy = self._dummy
00069         schemata = dummy.Schemata()
00070         base_names = getNames(schemata['default'])
00071         self.assertEqual(base_names, ['id', 'title'])

Here is the call graph for this function:

Definition at line 83 of file test_schemata.py.

00083 
00084     def test_dupe_accessor_names_add(self):
00085         a = Schemata(fields=(StringField('foo',
00086                                          accessor='getSomething',
00087                                          edit_accessor='editSomething',
00088                                          mutator='setSomething',
00089                                          ),))
00090         b = Schemata(fields=(StringField('bar',
00091                                          accessor='getSomething',
00092                                          edit_accessor='editThat',
00093                                          mutator='setThat',
00094                                          ),))
00095         self.assertRaises(SchemaException, operator.add, a, b)

Definition at line 127 of file test_schemata.py.

00127 
00128     def test_dupe_accessor_names_addField(self):
00129         a = Schemata(fields=(StringField('foo',
00130                                          accessor='getSomething',
00131                                          edit_accessor='editSomething',
00132                                          mutator='setSomething',
00133                                   ),))
00134         field = StringField('bar',
00135                             accessor='getSomething',
00136                             edit_accessor='editThat',
00137                             mutator='setThat',
00138                             )
00139         self.assertRaises(SchemaException, a.addField, field)

Definition at line 96 of file test_schemata.py.

00096 
00097     def test_dupe_edit_accessor_names_add(self):
00098         a = Schemata(fields=(StringField('foo',
00099                                          accessor='getSomething',
00100                                          edit_accessor='editSomething',
00101                                          mutator='setSomething',
00102                                          ),))
00103         b = Schemata(fields=(StringField('bar',
00104                                          accessor='getThat',
00105                                          edit_accessor='editSomething',
00106                                          mutator='setThat',
00107                                          ),))
00108         self.assertRaises(SchemaException, operator.add, a, b)

Definition at line 140 of file test_schemata.py.

00140 
00141     def test_dupe_edit_accessor_names_addField(self):
00142         a = Schemata(fields=(StringField('foo',
00143                                          accessor='getSomething',
00144                                          edit_accessor='editSomething',
00145                                          mutator='setSomething',
00146                                          ),))
00147         field = StringField('bar',
00148                             accessor='getThat',
00149                             edit_accessor='editSomething',
00150                             mutator='setThat',
00151                             )
00152         self.assertRaises(SchemaException, a.addField, field)

Definition at line 109 of file test_schemata.py.

00109 
00110     def test_dupe_mutator_names_add(self):
00111         a = Schemata(fields=(StringField('foo',
00112                                          accessor='getSomething',
00113                                          edit_accessor='editSomething',
00114                                          mutator='setSomething',
00115                                          ),))
00116         b = Schemata(fields=(StringField('bar',
00117                                          accessor='getThat',
00118                                          edit_accessor='editThat',
00119                                          mutator='setSomething',
00120                                          ),))
00121         self.assertRaises(SchemaException, operator.add, a, b)

Definition at line 153 of file test_schemata.py.

00153 
00154     def test_dupe_mutator_names_addField(self):
00155         a = Schemata(fields=(StringField('foo',
00156                                          accessor='getSomething',
00157                                          edit_accessor='editSomething',
00158                                          mutator='setSomething',
00159                                          ),))
00160         field = StringField('bar',
00161                             accessor='getThat',
00162                             edit_accessor='editThat',
00163                             mutator='setSomething',
00164                             )
00165         self.assertRaises(SchemaException, a.addField, field)

Definition at line 122 of file test_schemata.py.

00122 
00123     def test_dupe_primary_add(self):
00124         a = Schemata(fields=(StringField('foo', primary=True),))
00125         b = Schemata(fields=(StringField('bar', primary=True),))
00126         self.assertRaises(SchemaException, operator.add, a, b)

Definition at line 166 of file test_schemata.py.

00166 
00167     def test_dupe_primary_addField(self):
00168         a = Schemata(fields=(StringField('foo', primary=True),))
00169         field = StringField('bar', primary=True)
00170         self.assertRaises(SchemaException, a.addField, field)

Definition at line 171 of file test_schemata.py.

00171 
00172     def test_editableFields(self):
00173         # Not a security test, but this is here because 'editableFields'
00174         # will return only fields the user is allowed to write.
00175         dummy = self._dummy.__of__(self.folder)
00176         dummy.manage_permission(ModifyPortalContent, (user_role,))
00177 
00178         # add test fields to schema
00179         fields = (
00180             StringField(
00181                 'f1',
00182                 mutator='setF1',
00183                 write_permission = ModifyPortalContent,
00184                 widget=StringWidget(visible={'edit': 'invisible'}),
00185             ),
00186             StringField('f2', 
00187                 mutator='setF2',
00188                 write_permission = ModifyPortalContent,
00189                 widget=StringWidget(visible={'edit': 'hidden'}),
00190             ),
00191         )
00192 
00193         for f in fields:
00194             dummy.schema.addField(f)
00195 
00196         # add dummy mutators to pass the test in 'editableFields'
00197         def dummy_mutator(instance, value):
00198             pass
00199 
00200         dummy.setF1 = dummy_mutator
00201         dummy.setF2 = dummy_mutator
00202 
00203         # get editable fields
00204         schemata = dummy.Schemata()['default']
00205         editable_field_ids = [f.getName() for f in \
00206             schemata.editableFields(dummy, visible_only=True)]
00207 
00208         self.failUnless('f1' not in editable_field_ids)
00209         self.failUnless('f2' in editable_field_ids)

Here is the call graph for this function:

Definition at line 72 of file test_schemata.py.

00072 
00073     def test_metaschemata(self):
00074         dummy = self._dummy
00075         schemata = dummy.Schemata()
00076         meta_names = getNames(schemata['metadata'])
00077         self.assertEqual(meta_names, ['allowDiscussion', 'subject',
00078                                       'description', 'location', 'contributors',
00079                                       'creators', 'effectiveDate',
00080                                       'expirationDate', 'language',
00081                                       'rights', 'creation_date',
00082                                       'modification_date'])

Here is the call graph for this function:

Definition at line 60 of file test_schemata.py.

00060 
00061     def test_nameschemata(self):
00062         dummy = self._dummy
00063         schemata = dummy.Schemata()
00064         self.assertEqual(schemata['default'].getName(), 'default')
00065         self.assertEqual(schemata['metadata'].getName(), 'metadata')


Member Data Documentation

Definition at line 51 of file test_schemata.py.


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