source: products/quintagroup.gdocs.spreadsheet/trunk/quintagroup/gdocs/spreadsheet/README.txt @ 2725

Last change on this file since 2725 was 2725, checked in by liebster, 14 years ago

Added browser testing creation and modification GSpreadsheet

File size: 6.2 KB
Line 
1Introduction
2============
3
4This is a full-blown functional test. The emphasis here is on testing what
5the user may input and see, and the system is largely tested as a black box.
6We use PloneTestCase to set up this test as well, so we have a full Plone site
7to play with. We *can* inspect the state of the portal, e.g. using
8self.portal and self.folder, but it is often frowned upon since you are not
9treating the system as a black box. Also, if you, for example, log in or set
10roles using calls like self.setRoles(), these are not reflected in the test
11browser, which runs as a separate session.
12
13Being a doctest, we can tell a story here.
14
15First, we must perform some setup. We use the testbrowser that is shipped
16with Five, as this provides proper Zope 2 integration. Most of the
17documentation, though, is in the underlying zope.testbrower package.
18
19    >>> from Products.Five.testbrowser import Browser
20    >>> browser = Browser()
21    >>> portal_url = self.portal.absolute_url()
22
23The following is useful when writing and debugging testbrowser tests. It lets
24us see all error messages in the error_log.
25
26    >>> self.portal.error_log._ignored_exceptions = ()
27
28With that in place, we can go to the portal front page and log in. We will
29do this using the default user from PloneTestCase:
30
31    >>> from Products.PloneTestCase.setup import portal_owner, default_password
32
33    >>> browser.open(portal_url)
34
35We have the login portlet, so let's use that.
36
37    >>> browser.getLink('Log in').click()
38    >>> browser.getControl(name='__ac_name').value = portal_owner
39    >>> browser.getControl(name='__ac_password').value = default_password
40    >>> browser.getControl(name='submit').click()
41
42Here, we set the value of the fields on the login form and then simulate a
43submit click.
44
45We then test that we are still on the portal front page:
46
47    >>> browser.url == portal_url
48    True
49
50And we ensure that we get the friendly logged-in message:
51
52    >>> "You are now logged in" in browser.contents
53    True
54
55
56-*- extra stuff goes here -*-
57The GSpreadsheet content type
58===============================
59
60In this section we are tesing the GSpreadsheet content type by performing
61basic operations like adding, updadating and deleting GSpreadsheet content
62items.
63
64Adding a new GSpreadsheet content item
65--------------------------------
66
67We use the 'Add new' menu to add a new content item.
68
69    >>> browser.getLink('Add new').click()
70
71Then we select the type of item we want to add. In this case we select
72'GSpreadsheet' and click the 'Add' button to get to the add form.
73
74    >>> browser.getControl('GSpreadsheet').click()
75    >>> browser.getControl(name='form.button.Add').click()
76    >>> 'GSpreadsheet' in browser.contents
77    True
78
79Now we fill the form and submit it.
80
81    >>> browser.getControl(name='title').value = 'GSpreadsheet Sample'
82    >>> browser.getControl(name='spreadsheet_id').value = 'sp_id1'
83    >>> browser.getControl(name='worksheet_id').value = 'od6'
84    >>> browser.getControl('Save').click()
85    >>> 'Changes saved' in browser.contents
86    True
87
88And we are done! We added a new 'GSpreadsheet' content item to the portal.
89
90Updating an existing GSpreadsheet content item
91---------------------------------------
92
93Let's click on the 'edit' tab and update the object attribute values.
94
95    >>> browser.getLink('Edit').click()
96    >>> browser.getControl(name='title').value = 'New GSpreadsheet Sample'
97    >>> browser.getControl(name='spreadsheet_id').value = 'id1'
98    >>> browser.getControl(name='worksheet_id').value = 'od6'
99    >>> browser.getControl('Save').click()
100
101We check that the changes were applied.
102
103    >>> 'Changes saved' in browser.contents
104    True
105    >>> 'New GSpreadsheet Sample' in browser.contents
106    True
107
108Removing a/an GSpreadsheet content item
109--------------------------------
110
111If we go to the home page, we can see a tab with the 'New GSpreadsheet
112Sample' title in the global navigation tabs.
113
114    >>> browser.open(portal_url)
115    >>> 'New GSpreadsheet Sample' in browser.contents
116    True
117
118Now we are going to delete the 'New GSpreadsheet Sample' object. First we
119go to the contents tab and select the 'New GSpreadsheet Sample' for
120deletion.
121
122    >>> browser.getLink('Contents').click()
123    >>> browser.getControl('New GSpreadsheet Sample').click()
124
125We click on the 'Delete' button.
126
127    >>> browser.getControl('Delete').click()
128    >>> 'Item(s) deleted' in browser.contents
129    True
130
131So, if we go back to the home page, there is no longer a 'New GSpreadsheet
132Sample' tab.
133
134    >>> browser.open(portal_url)
135    >>> 'New GSpreadsheet Sample' in browser.contents
136    False
137
138Adding a new GSpreadsheet content item as contributor
139------------------------------------------------
140
141Not only site managers are allowed to add GSpreadsheet content items, but
142also site contributors.
143
144Let's logout and then login as 'contributor', a portal member that has the
145contributor role assigned.
146
147    >>> browser.getLink('Log out').click()
148    >>> browser.open(portal_url)
149    >>> browser.getLink('Log in').click()
150    >>> browser.getControl(name='__ac_name').value = 'contributor'
151    >>> browser.getControl(name='__ac_password').value = default_password
152    >>> browser.getControl(name='submit').click()
153    >>> browser.open(portal_url)
154
155We use the 'Add new' menu to add a new content item.
156
157    >>> browser.getLink('Add new').click()
158
159We select 'GSpreadsheet' and click the 'Add' button to get to the add form.
160
161    >>> browser.getControl('GSpreadsheet').click()
162    >>> browser.getControl(name='form.button.Add').click()
163    >>> 'GSpreadsheet' in browser.contents
164    True
165
166Now we fill the form and submit it.
167
168    >>> browser.getControl(name='title').value = 'GSpreadsheet Sample'
169    >>> browser.getControl(name='spreadsheet_id').value = 'sp_id1'
170    >>> browser.getControl(name='worksheet_id').value = 'od6'
171    >>> browser.getControl('Save').click()
172    >>> 'Changes saved' in browser.contents
173    True
174
175Done! We added a new GSpreadsheet content item logged in as contributor.
176
177Finally, let's login back as manager.
178
179    >>> browser.getLink('Log out').click()
180    >>> browser.open(portal_url)
181    >>> browser.getLink('Log in').click()
182    >>> browser.getControl(name='__ac_name').value = portal_owner
183    >>> browser.getControl(name='__ac_password').value = default_password
184    >>> browser.getControl(name='submit').click()
185    >>> browser.open(portal_url)
Note: See TracBrowser for help on using the repository browser.