Index: main/waeup.uniben/trunk/src/waeup/uniben/interswitch/tests.py
===================================================================
--- main/waeup.uniben/trunk/src/waeup/uniben/interswitch/tests.py	(revision 8265)
+++ main/waeup.uniben/trunk/src/waeup/uniben/interswitch/tests.py	(revision 8266)
@@ -18,4 +18,6 @@
 from hurry.workflow.interfaces import IWorkflowState
 from waeup.kofa.students.tests.test_browser import StudentsFullSetup
+from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
+from waeup.kofa.configuration import SessionConfiguration
 from waeup.uniben.testing import FunctionalLayer
 
@@ -36,5 +38,5 @@
 
 
-class InterswitchTests(StudentsFullSetup):
+class InterswitchTestsStudents(StudentsFullSetup):
     """Tests for the Interswitch payment gateway.
     """
@@ -43,5 +45,5 @@
 
     def setUp(self):
-        super(InterswitchTests, self).setUp()
+        super(InterswitchTestsStudents, self).setUp()
         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
         self.browser.open(self.payments_path)
@@ -56,4 +58,7 @@
         self.assertMatches('...Amount Authorized...',
                            self.browser.contents)
+        self.assertMatches(
+            '...<span>40000.0</span>...',
+            self.browser.contents)
         self.payment_url = self.browser.url
 
@@ -76,4 +81,6 @@
         self.assertMatches('...Total Amount Authorized:...',
                            self.browser.contents)
+        # The total amount to be processed by Interswitch
+        # has been reduced by the Interswitch fee of 150 Nairas
         self.assertMatches(
             '...<input type="hidden" name="amount" value="3985000.0" />...',
@@ -107,2 +114,63 @@
         self.assertMatches('...Unsuccessful callback...',
                           self.browser.contents)
+        # The payment is now in state failed
+        self.assertMatches('...<span>Failed</span>...',
+                          self.browser.contents)
+
+class InterswitchTestsApplicants(ApplicantsFullSetup):
+    """Tests for the Interswitch payment gateway.
+    """
+
+    layer = FunctionalLayer
+
+    def setUp(self):
+        super(InterswitchTestsApplicants, self).setUp()
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open(self.manage_path)
+        #IWorkflowState(self.student).setState('started')
+        super(InterswitchTestsApplicants, self).fill_correct_values()
+        self.browser.getControl(name="transition").value = ['start']
+        self.browser.getControl("Save").click()
+        self.browser.getControl("Add online").click()
+        self.assertTrue(
+            'Session configuration object is not available'
+            in self.browser.contents)
+        configuration = SessionConfiguration()
+        configuration.academic_session = 2009
+        configuration.application_fee = 1000.0
+        self.app['configuration'].addSessionConfiguration(configuration)
+        self.browser.getControl("Add online").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)
+        self.assertMatches(
+            '...<span>1000.0</span>...',
+            self.browser.contents)
+        self.payment_url = self.browser.url
+
+
+    def test_interswitch_form(self):
+
+        # Manager can access InterswitchForm
+        self.browser.getLink("CollegePAY", index=0).click()
+        self.assertMatches('...Total Amount Authorized:...',
+                           self.browser.contents)
+        # The total amount to be processed by Interswitch
+        # has been reduced by the Interswitch fee of 150 Nairas
+        self.assertMatches(
+            '...<input type="hidden" name="amount" value="85000.0" />...',
+            self.browser.contents)
+
+    @external_test
+    def test_webservice(self):
+
+        self.browser.open(self.payment_url + '/request_webservice')
+        self.assertMatches('...Unsuccessful callback...',
+                          self.browser.contents)
+        # The payment is now in state failed
+        self.assertMatches('...<span>Failed</span>...',
+                          self.browser.contents)
