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

Last change on this file since 5114 was 5108, checked in by uli, 15 years ago

Create a second batch during tests. This at least gives us better test
coverage.

File size: 3.3 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
24Access-code management screen
25=============================
26
27For users that have the right to manage access-code related stuff, the
28home page of a `University` instance provides a link to the
29access-code management screen. In the beginning, there are naturally
30no batches available:
31
32    >>> browser.open('http://localhost/myuniversity')
33    >>> browser.getLink('Manage access-codes').click()
34    >>> print browser.contents
35    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
36    ...
37    <h2>Access Code Batches</h2>
38    ...
39    ... The following batches are available:
40    ...No batches yet...
41    ...
42
43Adding batches
44==============
45
46We can add a batch of access-codes using a button displayed in the
47action bar:
48
49    >>> browser.getLink('Add Scratch Card Batch').click()
50
51The add screen shows a form where we have to enter a prefix, the
52number of access codes to be generated and the costs for each card.
53
54    >>> browser.getControl(name='form.batch_prefix').value = 'APP'
55    >>> browser.getControl(name='form.entry_num').value = '5'
56    >>> browser.getControl(name='form.cost').value = '12.12'
57
58If we click 'cancel' afterwards, the whole process will be cancelled
59and we'll be redirected to the management screen:
60
61    >>> browser.getControl('Cancel').click()
62    >>> browser.url
63    'http://localhost/myuniversity/accesscodes'
64
65    >>> 'Batch creation cancelled' in browser.contents
66    True
67
68Now let's try again and this time we finish the procedure by clicking
69'Create batch' in the form:
70
71    >>> browser.getLink('Add Scratch Card Batch').click()
72    >>> browser.getControl(name='form.batch_prefix').value = 'APP'
73    >>> browser.getControl(name='form.entry_num').value = '5'
74    >>> browser.getControl(name='form.cost').value = '12.12'
75    >>> browser.getControl('Create batch').click()
76
77We're also redirected to the management screen, with a notice about
78the freshly created batch:
79
80    >>> print browser.contents
81    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
82    ...
83    <h2>Access Code Batches</h2>
84    ...
85    ... The following batches are available:
86    ...APP
87    ...-
88    ...1
89    ...
90    ...5
91    .../
92    ...0
93    ...
94    ...12.12...
95    ...zope.mgr...
96    ...
97
98which means: there exists a batch named ``APP-1`` with 5 entries of
99which 0 have been devalidated, each one costs ``12.12`` and the batch
100was created by ``zope.mgr``.
101
102We create a second batch to see whether searching and related stuff
103works:
104
105    >>> browser.getLink('Add Scratch Card Batch').click()
106    >>> browser.getControl(name='form.batch_prefix').value = 'APP'
107    >>> browser.getControl(name='form.entry_num').value = '5'
108    >>> browser.getControl(name='form.cost').value = '10.12'
109    >>> browser.getControl('Create batch').click()
Note: See TracBrowser for help on using the repository browser.