source: main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/browser.txt @ 5119

Last change on this file since 5119 was 5115, checked in by uli, 15 years ago

Make sure we start with a fresh datacenter path, when testing
accesscodes. This brings us back to 100% test coverage for
accesscodes module.

File size: 4.0 KB
Line 
1Browsing the access-code related UI components
2**********************************************
3
4Here we visit the access-code related parts of a WAeUP SIRP site using
5a virtual browser.
6
7:Test-Layer: functional
8
9Preliminaries
10=============
11
12Before we can do anything, we have to create a university site:
13
14    >>> from zope.testbrowser.testing import Browser
15    >>> browser = Browser()
16    >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
17    >>> browser.handleErrors = False
18    >>> root = getRootFolder()
19
20    >>> from waeup.sirp.app import University
21    >>> u = University()
22    >>> root['myuniversity'] = u
23
24We set a new datacenter storage path:
25
26  >>> import os
27  >>> browser.open('http://localhost/myuniversity')
28  >>> browser.getLink('Data Center').click()
29  >>> browser.getLink('Edit settings').click()
30  >>> pathsetting = browser.getControl(name='newpath')
31
32  >>> cwd = os.getcwd()
33  >>> uploadpath = os.path.join(cwd, 'ac_testfiles')
34  >>> os.mkdir(uploadpath)
35  >>> pathsetting.value = uploadpath
36  >>> browser.getControl(name='save').click()
37
38We remove any existing 'accesscodes' dir from datacenter dir:
39
40  >>> import shutil
41  >>> if os.path.exists(os.path.join(uploadpath, 'accesscodes')):
42  ...   shutil.rmtree(os.path.join(uploadpath, 'accesscodes'))
43
44
45Access-code management screen
46=============================
47
48For users that have the right to manage access-code related stuff, the
49home page of a `University` instance provides a link to the
50access-code management screen. In the beginning, there are naturally
51no batches available:
52
53    >>> browser.open('http://localhost/myuniversity')
54    >>> browser.getLink('Manage access-codes').click()
55    >>> print browser.contents
56    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
57    ...
58    <h2>Access Code Batches</h2>
59    ...
60    ... The following batches are available:
61    ...No batches yet...
62    ...
63
64Adding batches
65==============
66
67We can add a batch of access-codes using a button displayed in the
68action bar:
69
70    >>> browser.getLink('Add Scratch Card Batch').click()
71
72The add screen shows a form where we have to enter a prefix, the
73number of access codes to be generated and the costs for each card.
74
75    >>> browser.getControl(name='form.batch_prefix').value = 'APP'
76    >>> browser.getControl(name='form.entry_num').value = '5'
77    >>> browser.getControl(name='form.cost').value = '12.12'
78
79If we click 'cancel' afterwards, the whole process will be cancelled
80and we'll be redirected to the management screen:
81
82    >>> browser.getControl('Cancel').click()
83    >>> browser.url
84    'http://localhost/myuniversity/accesscodes'
85
86    >>> 'Batch creation cancelled' in browser.contents
87    True
88
89Now let's try again and this time we finish the procedure by clicking
90'Create batch' in the form:
91
92    >>> browser.getLink('Add Scratch Card Batch').click()
93    >>> browser.getControl(name='form.batch_prefix').value = 'APP'
94    >>> browser.getControl(name='form.entry_num').value = '5'
95    >>> browser.getControl(name='form.cost').value = '12.12'
96    >>> browser.getControl('Create batch').click()
97
98We're also redirected to the management screen, with a notice about
99the freshly created batch:
100
101    >>> print browser.contents
102    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
103    ...
104    <h2>Access Code Batches</h2>
105    ...
106    ... The following batches are available:
107    ...APP
108    ...-
109    ...1
110    ...
111    ...5
112    .../
113    ...0
114    ...
115    ...12.12...
116    ...zope.mgr...
117    ...
118
119which means: there exists a batch named ``APP-1`` with 5 entries of
120which 0 have been devalidated, each one costs ``12.12`` and the batch
121was created by ``zope.mgr``.
122
123We create a second batch to see whether searching and related stuff
124works:
125
126    >>> browser.getLink('Add Scratch Card Batch').click()
127    >>> browser.getControl(name='form.batch_prefix').value = 'APP'
128    >>> browser.getControl(name='form.entry_num').value = '5'
129    >>> browser.getControl(name='form.cost').value = '10.12'
130    >>> browser.getControl('Create batch').click()
131
132Clean up:
133
134    >>> shutil.rmtree(uploadpath)
Note: See TracBrowser for help on using the repository browser.