Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
archetypes.kss.tests.test_fields.FieldsViewTestCase Class Reference
Inheritance diagram for archetypes.kss.tests.test_fields.FieldsViewTestCase:
Inheritance graph
[legend]
Collaboration diagram for archetypes.kss.tests.test_fields.FieldsViewTestCase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def testReplaceField
def testReplaceWithView
def testSaveField
def testSaveFieldWithEvents
def testSaveFieldWithValueFromRequest
def testReplaceFieldWithProvidedTargetNodeId
def testReplaceWithViewWithProvidedTargetNodeId
def testSaveFieldWithProvidedTargetNodeId
def testReplaceFieldWithProvidedContext
def testReplaceWithViewWithProvidedContext
def testSaveFieldWithProvidedContext
def testMarkerInATField
def testMarkerInATFieldInlineEditable
def testMarkerInNonATField
def testVersionPreviewIsNotInlineEditable
def loadCoreConfig
def createView
def setDebugRequest

Public Attributes

 view

Static Public Attributes

 layer = KSSAndPloneLayer

Private Member Functions

def _XXX_testSaveFieldWithVersioning

Detailed Description

Definition at line 35 of file test_fields.py.


Member Function Documentation

Definition at line 115 of file test_fields.py.

00115 
00116     def _XXX_testSaveFieldWithVersioning(self):
00117         view = self.view
00118         component.provideHandler(field_modified_handler)
00119         try:
00120             res = view.saveField('title', {'title':'My Title'}, 
00121                                     'kss_generic_macros', 'title-field-view')
00122             self.assert_(getattr(view.context, '_eventCaught', False))
00123             view.context._eventCaught = False
00124             res = view.saveField('description',
00125                                  {'description':'Woot a funky description!'},
00126                                  'kss_generic_macros', 'description-field-view')
00127             self.assert_(getattr(view.context, '_eventCaught', False))
00128         finally:
00129             sm = component.getSiteManager()
00130             sm.unregisterHandler(field_modified_handler)

Definition at line 37 of file test_fields.py.

00037 
00038     def afterSetUp(self):
00039         PloneTestCase.PloneTestCase.afterSetUp(self)
00040         # commands will be rendered as data structures,
00041         self.setDebugRequest()
00042         self.loginAsPortalOwner()
00043         context = self.portal['front-page']
00044         # Set up a view 
00045         self.view = context.restrictedTraverse('saveField')

Here is the call graph for this function:

Definition at line 108 of file base.py.

00108 
00109     def createView(self):
00110         "Set up a fake view (with no content)"
00111         self.view = self.folder.restrictedTraverse('testMethod')
00112         return self.view

Here is the caller graph for this function:

def kss.core.tests.base.KSSViewTestCaseMixin.loadCoreConfig (   self,
  kss_core = True 
) [inherited]

Definition at line 102 of file base.py.

00102 
00103     def loadCoreConfig(self, kss_core=True):
00104         warnings.warn(
00105             "KSS tests are now using layers.  Please do not use "
00106             "loadCoreConfig anymore.",
00107             DeprecationWarning)
    

Definition at line 113 of file base.py.

00113 
00114     def setDebugRequest(self):
00115         'commands will be rendered as test friendly data structures'
00116         request = self.folder.REQUEST
00117         interface.directlyProvides(
00118             request,
00119             interface.directlyProvidedBy(request) + IDebugRequest)

Here is the caller graph for this function:

Definition at line 224 of file test_fields.py.

00224 
00225     def testMarkerInATField(self):
00226         # writeable
00227         view = self.portal['front-page'].restrictedTraverse('kss_field_decorator_view')
00228         result = view.getKssClasses('title')
00229         self.assertEqual(result, ' kssattr-atfieldname-title')
00230         result = view.getKssClasses('title', 'template')
00231         self.assertEqual(result, ' kssattr-atfieldname-title kssattr-templateId-template')
00232         result = view.getKssClasses('title', 'template', 'macro')
00233         self.assertEqual(result, ' kssattr-atfieldname-title kssattr-templateId-template kssattr-macro-macro')
00234         self.logout()
00235         result = view.getKssClasses('title')
00236         # not writeable
00237         self.assertEqual(result, '')

Here is the call graph for this function:

Definition at line 238 of file test_fields.py.

00238 
00239     def testMarkerInATFieldInlineEditable(self):
00240         # writeable
00241         view = self.portal['front-page'].restrictedTraverse('kss_field_decorator_view')
00242         result = view.getKssClassesInlineEditable('title', 'template')
00243         self.assertEqual(result, ' kssattr-atfieldname-title kssattr-templateId-template inlineEditable')
00244         result = view.getKssClassesInlineEditable('title', 'template', 'macro')
00245         self.assertEqual(result, ' kssattr-atfieldname-title kssattr-templateId-template kssattr-macro-macro inlineEditable')
00246         self.logout()
00247         # not writeable
00248         result = view.getKssClassesInlineEditable('title', 'template')
00249         self.assertEqual(result, '')

Here is the call graph for this function:

Definition at line 250 of file test_fields.py.

00250 
00251     def testMarkerInNonATField(self):
00252         # portal root is not an AT object
00253         view = self.portal.restrictedTraverse('kss_field_decorator_view')
00254         result = view.getKssClasses('title')
00255         # not writeable
00256         self.assertEqual(result, '')

Definition at line 50 of file test_fields.py.

00050 
00051     def testReplaceField(self):
00052         self.view.context.changeSkin('Plone Default', self.view.request)
00053         result = self.view.replaceField('title', 'kss_generic_macros', 'title-field-view')
00054         self.assertEqual([(r['name'], r['selector'], r['selectorType'])
00055                              for r in result], [
00056             ('setStyle', '.portalMessage', 'css'),
00057             ('replaceInnerHTML', 'kssPortalMessage', 'htmlid'),
00058             ('setAttribute', 'kssPortalMessage', 'htmlid'),
00059             ('setStyle', 'kssPortalMessage', 'htmlid'),
00060             ('replaceHTML', 'parent-fieldname-title', 'htmlid'),
00061             ('focus', '#parent-fieldname-title .firstToFocus', '')
00062         ])

Definition at line 170 of file test_fields.py.

00170 
00171     def testReplaceFieldWithProvidedContext(self):
00172         # set the global context to /news
00173         context = self.portal['news']
00174         view = context.restrictedTraverse('saveField')
00175         context.changeSkin('Plone Default', view.request)
00176 
00177         frontpage_uid = self.portal['front-page'].UID()
00178         result = view.replaceField('title', 'kss_generic_macros', 'title-field-view', uid=frontpage_uid)
00179 
00180         self.assertEqual([(r['name'], r['selector'], r['selectorType'])
00181                              for r in result], [
00182             ('setStyle', '.portalMessage', 'css'),
00183             ('replaceInnerHTML', 'kssPortalMessage', 'htmlid'),
00184             ('setAttribute', 'kssPortalMessage', 'htmlid'),
00185             ('setStyle', 'kssPortalMessage', 'htmlid'),
00186             ('replaceHTML', 'parent-fieldname-title', 'htmlid'),
00187             ('focus', '#parent-fieldname-title .firstToFocus', '')
00188         ])
00189 
00190         # make sure we've got the right context:
00191         replaceHTML = ''.join([r['params'].get('html', '') for r in result])
00192         self.assertEqual(u"Welcome to Plone" in replaceHTML, True)       

Here is the call graph for this function:

Definition at line 136 of file test_fields.py.

00136 
00137     def testReplaceFieldWithProvidedTargetNodeId(self):
00138         self.view.context.changeSkin('Plone Default', self.view.request)
00139         target = 'parent-fieldname-title'
00140         result = self.view.replaceField('title', 'kss_generic_macros', 'title-field-view', target=target)
00141         self.assertEqual([(r['name'], r['selector'], r['selectorType'])
00142                              for r in result], [
00143             ('setStyle', '.portalMessage', 'css'),
00144             ('replaceInnerHTML', 'kssPortalMessage', 'htmlid'),
00145             ('setAttribute', 'kssPortalMessage', 'htmlid'),
00146             ('setStyle', 'kssPortalMessage', 'htmlid'),
00147             ('replaceHTML', 'parent-fieldname-title', 'htmlid'),
00148             ('focus', '#parent-fieldname-title .firstToFocus', '')
00149         ])

Definition at line 63 of file test_fields.py.

00063 
00064     def testReplaceWithView(self):
00065         self.view.context.changeSkin('Plone Default', self.view.request)
00066         result = self.view.replaceWithView('title', 'kss_generic_macros', 'title-field-view')
00067         self.assertEqual([(r['name'], r['selector'], r['selectorType'])
00068                              for r in result], [
00069              ('replaceHTML', 'parent-fieldname-title', 'htmlid'),
00070             ])

Definition at line 193 of file test_fields.py.

00193 
00194     def testReplaceWithViewWithProvidedContext(self):
00195         # set the global context to /news
00196         context = self.portal['news']
00197         view = context.restrictedTraverse('saveField')
00198         context.changeSkin('Plone Default', view.request)
00199 
00200         frontpage_uid = self.portal['front-page'].UID()
00201         result = view.replaceWithView('title', 'kss_generic_macros', 'title-field-view', uid=frontpage_uid)
00202 
00203         self.assertEqual([(r['name'], r['selector'], r['selectorType'])
00204                              for r in result], [
00205              ('replaceHTML', 'parent-fieldname-title', 'htmlid'),
00206             ])
00207 
00208         # make sure we've got the right context:
00209         replaceHTML = ''.join([r['params'].get('html', '') for r in result])
00210         self.assertEqual(u"Welcome to Plone" in replaceHTML, True)       

Here is the call graph for this function:

Definition at line 150 of file test_fields.py.

00150 
00151     def testReplaceWithViewWithProvidedTargetNodeId(self):
00152         self.view.context.changeSkin('Plone Default', self.view.request)
00153         target = 'parent-fieldname-title'
00154         result = self.view.replaceWithView('title', 'kss_generic_macros', 'title-field-view', target=target)
00155         self.assertEqual([(r['name'], r['selector'], r['selectorType'])
00156                              for r in result], [
00157              ('replaceHTML', 'parent-fieldname-title', 'htmlid'),
00158             ])

Definition at line 73 of file test_fields.py.

00073 
00074     def testSaveField(self):
00075         view = self.view
00076         result = view.saveField('title', {'title':'My Title'}, 
00077                                 'kss_generic_macros', 'title-field-view')
00078         self.assertEqual([(r['name'], r['selector'], r['selectorType'])
00079                              for r in result], [
00080              ('replaceHTML', 'parent-fieldname-title', 'htmlid'),
00081             ])
00082         self.assertEqual('My Title', self.portal['front-page'].Title())
00083         res = view.saveField('description',
00084                              {'description':'Woot a funky description!'},
00085                              'kss_generic_macros', 'description-field-view')
00086         self.assertEqual('Woot a funky description!', self.portal['front-page'].Description())
00087     

Here is the call graph for this function:

Definition at line 89 of file test_fields.py.

00089 
00090     def testSaveFieldWithEvents(self):
00091         view = self.view
00092         result = view.saveField('title', {'title':'My Title'}, 
00093                                 'kss_generic_macros', 'title-field-view')
00094         self.assertEqual('My Title', self.portal['front-page'].Title())
00095         res = view.saveField('description',
00096                              {'description':'Woot a funky description!'},
00097                              'kss_generic_macros', 'description-field-view')
00098         self.assertEqual('Woot a funky description!', self.portal['front-page'].Description())
00099 

Here is the call graph for this function:

Definition at line 211 of file test_fields.py.

00211 
00212     def testSaveFieldWithProvidedContext(self):
00213         # set the global context to /news
00214         context = self.portal['news']
00215         view = context.restrictedTraverse('saveField')
00216         context.changeSkin('Plone Default', view.request)
00217 
00218         frontpage_uid = self.portal['front-page'].UID()
00219         result = view.saveField('title', {'title': 'My Title'},
00220                                 'kss_generic_macros', 'title-field-view', uid=frontpage_uid)
00221 
00222         self.assertEqual('My Title', self.portal['front-page'].Title())
00223 
    

Here is the call graph for this function:

Definition at line 159 of file test_fields.py.

00159 
00160     def testSaveFieldWithProvidedTargetNodeId(self):
00161         view = self.view
00162         target = 'parent-fieldname-title'
00163         result = view.saveField('title', {'title':'My Title'}, 
00164                                 'kss_generic_macros', 'title-field-view', target=target)
00165         self.assertEqual([(r['name'], r['selector'], r['selectorType'])
00166                              for r in result], [
00167              ('replaceHTML', 'parent-fieldname-title', 'htmlid'),
00168             ])
00169         self.assertEqual('My Title', self.portal['front-page'].Title())

Here is the call graph for this function:

Definition at line 100 of file test_fields.py.

00100 
00101     def testSaveFieldWithValueFromRequest(self):
00102         view = self.view
00103         view.request.form['title'] = 'My Title'
00104         view.request.form['description'] = 'Woot a funky description!'
00105         result = view.saveField('title', None, 
00106                                 'kss_generic_macros', 'title-field-view')
00107         self.assertEqual('My Title', self.portal['front-page'].Title())
00108         res = view.saveField('description',
00109                              None,
00110                              'kss_generic_macros', 'description-field-view')
00111         self.assertEqual('Woot a funky description!', 
00112                          self.portal['front-page'].Description())

Here is the call graph for this function:

If the kss_inline_editable variable is defined to False
in a page template, all the fields will be globally prohibited 
to be editable. This works via the getKssClasses method.
Similarly, is suppress_preview is set to true, inline
editing is prohibited. This is set from CMFEditions, in the
versions_history_form.

In this test we check that the versions history is not
inline editable at all.

Definition at line 257 of file test_fields.py.

00257 
00258     def testVersionPreviewIsNotInlineEditable(self):
00259         """If the kss_inline_editable variable is defined to False
00260         in a page template, all the fields will be globally prohibited 
00261         to be editable. This works via the getKssClasses method.
00262         Similarly, is suppress_preview is set to true, inline
00263         editing is prohibited. This is set from CMFEditions, in the
00264         versions_history_form.
00265 
00266         In this test we check that the versions history is not
00267         inline editable at all.
00268         """
00269         obj = self.portal['front-page']
00270         # Make sure we actually have a revision
00271         pr = self.portal.portal_repository
00272         pr.save(obj)
00273         # Render versions history of the front page
00274         obj.REQUEST.form['version_id'] = '0'
00275         rendered = obj.versions_history_form()
00276         soup = BeautifulSoup(rendered)
00277         # check that inline edit is not active, by looking at title
00278         tag = soup.find(id='parent-fieldname-title')
00279         klass = tag['class']
00280         # just to check that we are looking at the right bit...
00281         # XXX but this is no more, we can't check it
00282         #self.assert_('documentFirstHeading' in klass)
00283         # ... and now see we are really not inline editable:
00284         self.assert_('inlineEditable' not in klass)
00285         # make sure the rest is still there or instant validation and possibly
00286         # other stuff will fail
00287         self.assert_('kssattr-templateId-' in klass)
00288         self.assert_('kssattr-macro-' in klass)

Here is the call graph for this function:


Member Data Documentation

Definition at line 25 of file kss_and_plone_layer.py.

Reimplemented from kss.core.tests.base.KSSViewTestCaseMixin.

Definition at line 44 of file test_fields.py.


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