source: products/quintagroup.portlet.static/trunk/quintagroup/portlet/static/configlet.txt @ 3218

Last change on this file since 3218 was 616, checked in by fenix, 17 years ago

fixed view template for campaign content type and increment product version

  • Property svn:eol-style set to native
File size: 4.7 KB
Line 
1Static Stylish portlet configlet
2================================
3
4Static Stylish portlet ships with it's own configuration page which you can
5access at:
6    ${your/portal/url}/@@staticstylishportlet-controlpanel
7
8or from Plone Control Panel under 'Add-on Product Configuration' section.
9
10
11Prepare testing environment
12---------------------------
13
14We use zope.testbrowser to simulate browser interaction in order to show
15the main flow of pages. This is not a true functional test, because we also
16inspect and modify the internal state of the ZODB, but it is a useful way of
17making sure we test the full end-to-end process of creating and modifying
18content.
19
20    >>> from Products.Five.testbrowser import Browser
21    >>> browser = Browser()
22    >>> portal_url = self.portal.absolute_url()
23
24The following is useful when writing and debugging testbrowser tests. It lets
25us see error messages properly.
26
27    >>> browser.handleErrors = False
28    >>> self.portal.error_log._ignored_exceptions = ()
29
30We then turn off the various portlets, because they sometimes duplicate links
31and text (e.g. the navtree, the recent recent items listing) that we wish to
32test for in our own views. Having no portlets makes things easier.
33
34    >>> from zope.component import getUtility, getMultiAdapter
35    >>> from plone.portlets.interfaces import IPortletManager
36    >>> from plone.portlets.interfaces import IPortletAssignmentMapping
37
38    >>> left_column = getUtility(IPortletManager, name=u"plone.leftcolumn")
39    >>> left_assignable = getMultiAdapter((self.portal, left_column), IPortletAssignmentMapping)
40    >>> for name in left_assignable.keys():
41    ...     del left_assignable[name]
42
43    >>> right_column = getUtility(IPortletManager, name=u"plone.rightcolumn")
44    >>> right_assignable = getMultiAdapter((self.portal, right_column), IPortletAssignmentMapping)
45    >>> for name in right_assignable.keys():
46    ...     del right_assignable[name]
47
48
49Finally, we need to log in as the portal owner, i.e. an administrator user. We
50do this from the login page.
51
52    >>> from Products.PloneTestCase.setup import portal_owner, default_password
53    >>> browser.open(portal_url + '/login_form?came_from=' + portal_url)
54    >>> browser.getControl(name='__ac_name').value = portal_owner
55    >>> browser.getControl(name='__ac_password').value = default_password
56    >>> browser.getControl(name='submit').click()
57
58
59Configlet Registration
60----------------------
61
62Firstly check whether configlet is really registered:
63
64    >>> from Products.CMFCore.utils import getToolByName
65    >>> cp = getToolByName(self.portal, 'portal_controlpanel')
66    >>> actions = [a.id for a in cp.listActions()]
67    >>> 'StaticStylishPortlet' in actions
68    True
69
70
71Access to configlet
72-------------------
73
74Let's see if we can go to /@@staticstylishportlet-controlpanel url.
75
76    >>> browser.open('%s/@@staticstylishportlet-controlpanel' % portal_url)
77
78Is there configlet title on the requested page?
79
80    >>> 'Static Stylish portlet settings' in browser.contents
81    True
82
83
84Configlet Validation Functionality
85----------------------------------
86
87Check whether validation is working properly. Set no value to new entry item.
88
89    >>> browser.getControl(name='form.portlet_dropdown.add').click()
90    >>> browser.getControl(name='form.portlet_dropdown.1.value').value = ''
91
92Now save form. We shoud obtain missing value error:
93
94    >>> browser.getControl(name='form.actions.save').click()
95    >>> 'value: Required input is missing.' in browser.contents
96    True
97
98
99Configlet Save Functionality
100----------------------------
101
102It's time to correct previous error-prone situation. Set missing value.
103
104    >>> browser.getControl(name='form.portlet_dropdown.1.value').value = 'new_value'
105
106And submit form again. This time we should see 'Changes saved.' message:
107
108    >>> browser.getControl(name='form.actions.save').click()
109    >>> 'Changes saved.' in browser.contents
110    True
111
112and value should be duplicated into title field since we left title input empty:
113
114    >>> browser.getControl(name='form.portlet_dropdown.1.title').value
115    'new_value'
116
117And finally check portal_properties to ensure our settings page did everything
118correctly on the back end:
119
120    >>> sheet = getToolByName(self.portal, 'portal_properties').staticportlet_properties
121    >>> 'new_value|new_value' in sheet.getProperty('portlet_dropdown')
122    True
123
124
125Configlet Cancel Functionality
126------------------------------
127
128The last thing we are going to check is configlet's Cancel button:
129
130    >>> browser.getControl(name='form.actions.cancel').click()
131    >>> 'Changes canceled.' in browser.contents
132    True
133
134    >>> browser.url.endswith('/plone_control_panel')
135    True
136
137As you can see Cancel button redirected us to Plone Control Panel.
138
139
140That's it.
141
142
143
144
Note: See TracBrowser for help on using the repository browser.