source: products/ploneorg.kudobounty/trunk/ploneorg/kudobounty/README.txt @ 3129

Last change on this file since 3129 was 3129, checked in by mylan, 13 years ago

Initial import of the package

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