[5105] | 1 | Browsing the access-code related UI components |
---|
| 2 | ********************************************** |
---|
| 3 | |
---|
| 4 | Here we visit the access-code related parts of a WAeUP SIRP site using |
---|
| 5 | a virtual browser. |
---|
| 6 | |
---|
| 7 | :Test-Layer: functional |
---|
| 8 | |
---|
| 9 | Preliminaries |
---|
| 10 | ============= |
---|
| 11 | |
---|
| 12 | Before 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 | |
---|
| 24 | Access-code management screen |
---|
| 25 | ============================= |
---|
| 26 | |
---|
| 27 | For users that have the right to manage access-code related stuff, the |
---|
| 28 | home page of a `University` instance provides a link to the |
---|
| 29 | access-code management screen. In the beginning, there are naturally |
---|
| 30 | no 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 | |
---|
| 43 | Adding batches |
---|
| 44 | ============== |
---|
| 45 | |
---|
| 46 | We can add a batch of access-codes using a button displayed in the |
---|
| 47 | action bar: |
---|
| 48 | |
---|
| 49 | >>> browser.getLink('Add Scratch Card Batch').click() |
---|
| 50 | |
---|
| 51 | The add screen shows a form where we have to enter a prefix, the |
---|
| 52 | number 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 | |
---|
| 58 | If we click 'cancel' afterwards, the whole process will be cancelled |
---|
| 59 | and 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 | |
---|
| 68 | Now 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 | |
---|
| 77 | We're also redirected to the management screen, with a notice about |
---|
| 78 | the 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 | |
---|
| 98 | which means: there exists a batch named ``APP-1`` with 5 entries of |
---|
| 99 | which 0 have been devalidated, each one costs ``12.12`` and the batch |
---|
| 100 | was created by ``zope.mgr``. |
---|