Index: main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py	(revision 6941)
+++ main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py	(revision 6942)
@@ -659,8 +659,7 @@
         self.app['configuration'].addSessionConfiguration(configuration)
 
-        # Managers can add and remove online school fee payment tickets
+        # Managers can add online school fee payment tickets
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
         self.browser.open(self.payments_student_path)
-        #self.browser.getLink("Manage").click()
         self.browser.getControl("Add online payment ticket").click()
         self.browser.getControl(name="form.p_category").value = ['schoolfee']
@@ -673,6 +672,13 @@
         self.assertMatches('...Amount Authorized...',
                            self.browser.contents)
+
+        # Managers can open the callback view which simulates a valid callback
+        self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
+        self.browser.open(self.browser.url + '/callback')
+        self.assertMatches('...Valid callback received...',
+                          self.browser.contents)
+
+        # Managers can remove online school fee payment tickets
         self.browser.open(self.payments_student_path)
-        #self.browser.getLink('Manage').click()
         self.browser.getControl("Remove selected").click()
         self.assertMatches('...No payment selected...', self.browser.contents)
@@ -719,13 +725,26 @@
                            self.browser.contents)
 
-        # Managers can add online schoolfee payment tickets
+
+
+    def test_student_payments(self):
+        # Set up SessionConfiguration object
+        configuration = SessionConfiguration()
+        configuration.academic_session = 2004
+        configuration.fee_1 = 20000
+        self.app['configuration'].addSessionConfiguration(configuration)
+        self.browser.open(self.login_path)
+        self.browser.getControl(name="form.login").value = self.student_id
+        self.browser.getControl(name="form.password").value = 'spwd'
+        self.browser.getControl("Login").click()
+
+        # Students can add online clearance payment tickets
         self.browser.open(self.payments_student_path + '/addop')
-        self.browser.getControl(name="form.p_category").value = ['schoolfee']
+        self.browser.getControl(name="form.p_category").value = ['clearance']
         self.browser.getControl("Create ticket").click()
         self.assertMatches('...ticket created...',
                            self.browser.contents)
 
-        # Managers can open the callback view which simulates a valid callback
-        self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
+        # Students can open the callback view which simulates a valid callback
+        self.assertEqual(len(self.app['accesscodes']['CLR-0']),0)
         ctrl = self.browser.getControl(name='val_id')
         value = ctrl.options[0]
@@ -734,2 +753,56 @@
         self.assertMatches('...Valid callback received...',
                           self.browser.contents)
+        expected = '''...
+        <td>
+          Paid
+        </td>...'''
+        self.assertMatches(expected,self.browser.contents)
+        # The new CLR-0 pin has been created
+        self.assertEqual(len(self.app['accesscodes']['CLR-0']),1)
+        pin = self.app['accesscodes']['CLR-0'].keys()[0]
+        ac = self.app['accesscodes']['CLR-0'][pin]
+        ac.owner = self.student_id
+        # The new CLR-0 pin can be used for starting clearance
+        IWorkflowInfo(self.student).fireTransition('admit')
+        self.browser.open(self.student_path + '/start_clearance')
+        parts = pin.split('-')[1:]
+        clrseries, clrnumber = parts
+        self.browser.getControl(name="ac_series").value = clrseries
+        self.browser.getControl(name="ac_number").value = clrnumber
+        self.browser.getControl("Start clearance now").click()
+        self.assertMatches('...Clearance process has been started...',
+                           self.browser.contents)
+
+        # Students can add online school fee payment tickets
+        self.browser.open(self.payments_student_path)
+        self.browser.getControl("Add online payment ticket").click()
+        self.browser.getControl(name="form.p_category").value = ['schoolfee']
+        self.browser.getControl("Create ticket").click()
+        self.assertMatches('...ticket created...',
+                           self.browser.contents)
+        ctrl = self.browser.getControl(name='val_id')
+        value = ctrl.options[0]
+        self.browser.getLink(value).click()
+        self.assertMatches('...Amount Authorized...',
+                           self.browser.contents)
+
+        # Students can open the callback view which simulates a valid callback
+        self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
+        self.browser.open(self.browser.url + '/callback')
+        self.assertMatches('...Valid callback received...',
+                          self.browser.contents)
+
+        # Students can remove only online payment tickets which have
+        # not received a valid callback
+        self.browser.open(self.payments_student_path)
+        self.assertRaises(
+            LookupError, self.browser.getControl, name='val_id')
+        self.browser.open(self.payments_student_path + '/addop')
+        self.browser.getControl(name="form.p_category").value = ['gown']
+        self.browser.getControl("Create ticket").click()
+        self.browser.open(self.payments_student_path)
+        ctrl = self.browser.getControl(name='val_id')
+        value = ctrl.options[0]
+        ctrl.getControl(value=value).selected = True
+        self.browser.getControl("Remove selected", index=0).click()
+        self.assertTrue('Successfully removed' in self.browser.contents)
