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

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

Add contenttype using paster

File size: 5.7 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.getControl(name='__ac_name').value = portal_owner
38    >>> browser.getControl(name='__ac_password').value = default_password
39    >>> browser.getControl(name='submit').click()
40
41Here, we set the value of the fields on the login form and then simulate a
42submit click.
43
44We then test that we are still on the portal front page:
45
46    >>> browser.url == portal_url
47    True
48
49And we ensure that we get the friendly logged-in message:
50
51    >>> "You are now logged in" in browser.contents
52    True
53
54
55-*- extra stuff goes here -*-
56The GSpreadsheet content type
57===============================
58
59In this section we are tesing the GSpreadsheet content type by performing
60basic operations like adding, updadating and deleting GSpreadsheet content
61items.
62
63Adding a new GSpreadsheet content item
64--------------------------------
65
66We use the 'Add new' menu to add a new content item.
67
68    >>> browser.getLink('Add new').click()
69
70Then we select the type of item we want to add. In this case we select
71'GSpreadsheet' and click the 'Add' button to get to the add form.
72
73    >>> browser.getControl('GSpreadsheet').click()
74    >>> browser.getControl(name='form.button.Add').click()
75    >>> 'GSpreadsheet' in browser.contents
76    True
77
78Now we fill the form and submit it.
79
80    >>> browser.getControl(name='title').value = 'GSpreadsheet Sample'
81    >>> browser.getControl('Save').click()
82    >>> 'Changes saved' in browser.contents
83    True
84
85And we are done! We added a new 'GSpreadsheet' content item to the portal.
86
87Updating an existing GSpreadsheet content item
88---------------------------------------
89
90Let's click on the 'edit' tab and update the object attribute values.
91
92    >>> browser.getLink('Edit').click()
93    >>> browser.getControl(name='title').value = 'New GSpreadsheet Sample'
94    >>> browser.getControl('Save').click()
95
96We check that the changes were applied.
97
98    >>> 'Changes saved' in browser.contents
99    True
100    >>> 'New GSpreadsheet Sample' in browser.contents
101    True
102
103Removing a/an GSpreadsheet content item
104--------------------------------
105
106If we go to the home page, we can see a tab with the 'New GSpreadsheet
107Sample' title in the global navigation tabs.
108
109    >>> browser.open(portal_url)
110    >>> 'New GSpreadsheet Sample' in browser.contents
111    True
112
113Now we are going to delete the 'New GSpreadsheet Sample' object. First we
114go to the contents tab and select the 'New GSpreadsheet Sample' for
115deletion.
116
117    >>> browser.getLink('Contents').click()
118    >>> browser.getControl('New GSpreadsheet Sample').click()
119
120We click on the 'Delete' button.
121
122    >>> browser.getControl('Delete').click()
123    >>> 'Item(s) deleted' in browser.contents
124    True
125
126So, if we go back to the home page, there is no longer a 'New GSpreadsheet
127Sample' tab.
128
129    >>> browser.open(portal_url)
130    >>> 'New GSpreadsheet Sample' in browser.contents
131    False
132
133Adding a new GSpreadsheet content item as contributor
134------------------------------------------------
135
136Not only site managers are allowed to add GSpreadsheet content items, but
137also site contributors.
138
139Let's logout and then login as 'contributor', a portal member that has the
140contributor role assigned.
141
142    >>> browser.getLink('Log out').click()
143    >>> browser.open(portal_url)
144    >>> browser.getControl(name='__ac_name').value = 'contributor'
145    >>> browser.getControl(name='__ac_password').value = default_password
146    >>> browser.getControl(name='submit').click()
147    >>> browser.open(portal_url)
148
149We use the 'Add new' menu to add a new content item.
150
151    >>> browser.getLink('Add new').click()
152
153We select 'GSpreadsheet' and click the 'Add' button to get to the add form.
154
155    >>> browser.getControl('GSpreadsheet').click()
156    >>> browser.getControl(name='form.button.Add').click()
157    >>> 'GSpreadsheet' in browser.contents
158    True
159
160Now we fill the form and submit it.
161
162    >>> browser.getControl(name='title').value = 'GSpreadsheet Sample'
163    >>> browser.getControl('Save').click()
164    >>> 'Changes saved' in browser.contents
165    True
166
167Done! We added a new GSpreadsheet content item logged in as contributor.
168
169Finally, let's login back as manager.
170
171    >>> browser.getLink('Log out').click()
172    >>> browser.open(portal_url)
173    >>> browser.getControl(name='__ac_name').value = portal_owner
174    >>> browser.getControl(name='__ac_password').value = default_password
175    >>> browser.getControl(name='submit').click()
176    >>> browser.open(portal_url)
177
178
179
Note: See TracBrowser for help on using the repository browser.