Index: main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 13051)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 13059)
@@ -25,5 +25,6 @@
 from hurry.workflow.interfaces import IWorkflowState
 from zope.component.hooks import setSite, clearSite
-from zope.component import getUtility, createObject
+from zope.component import getUtility, createObject, queryUtility
+from zope.catalog.interfaces import ICatalog
 from waeup.kofa.app import University
 from waeup.kofa.students.tests.test_browser import StudentsFullSetup
@@ -99,20 +100,4 @@
         return
 
-class StudentUITests(StudentsFullSetup):
-    """Tests for customized student class views and pages
-    """
-
-    layer = FunctionalLayer
-
-    def setUp(self):
-        super(StudentUITests, self).setUp()
-
-        bedticket = BedTicket()
-        bedticket.booking_session = 2004
-        bedticket.bed_type = u'any bed type'
-        bedticket.bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
-        bedticket.bed_coordinates = u'My bed coordinates'
-        self.student['accommodation'].addBedTicket(bedticket)
-
     def test_manage_payments(self):
         # Add missing configuration data
@@ -245,4 +230,63 @@
         self.assertMatches('...Session configuration object is not...',
                            self.browser.contents)
+
+    def test_manage_payments_bypass_ac_creation(self):
+        self.app['configuration']['2004'].school_fee_1 = 6666.0
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open(self.payments_path)
+        IWorkflowState(self.student).setState('cleared')
+        self.browser.getLink("Add current session payment ticket").click()
+        self.browser.getControl(name="form.p_category").value = ['schoolfee']
+        self.browser.getControl("Create ticket").click()
+        ctrl = self.browser.getControl(name='val_id')
+        value = ctrl.options[0]
+        self.browser.getLink(value).click()
+        payment_url = self.browser.url
+        logfile = os.path.join(
+            self.app['datacenter'].storage, 'logs', 'students.log')
+        # The ticket can be found in the payments_catalog
+        cat = queryUtility(ICatalog, name='payments_catalog')
+        results = list(cat.searchResults(p_state=('unpaid', 'unpaid')))
+        self.assertTrue(len(results), 1)
+        self.assertTrue(results[0] is self.student['payments'][value])
+        # Managers can approve the payment
+        self.browser.open(payment_url)
+        self.browser.getLink("Approve payment").click()
+        self.assertMatches('...Payment approved...',
+                          self.browser.contents)
+        # Approval is logged in students.log ...
+        logcontent = open(logfile).read()
+        self.assertTrue(
+            'zope.mgr - students.browser.OnlinePaymentApproveView '
+            '- E1000000 - schoolfee payment approved'
+            in logcontent)
+        # ... and in payments.log
+        logfile = os.path.join(
+            self.app['datacenter'].storage, 'logs', 'payments.log')
+        logcontent = open(logfile).read()
+        self.assertTrue(
+            '"zope.mgr",E1000000,%s,schoolfee,6666.0,AP,,,,,,\n' % value
+            in logcontent)
+        # Student is in state school fee paid, no activation
+        # code was necessary.
+        self.assertEqual(self.student.state, 'school fee paid')
+        self.assertEqual(len(self.app['accesscodes']['SFE-0']),0)
+        return
+
+class StudentUITests(StudentsFullSetup):
+    """Tests for customized student class views and pages
+    """
+
+    layer = FunctionalLayer
+
+    def setUp(self):
+        super(StudentUITests, self).setUp()
+
+        bedticket = BedTicket()
+        bedticket.booking_session = 2004
+        bedticket.bed_type = u'any bed type'
+        bedticket.bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
+        bedticket.bed_coordinates = u'My bed coordinates'
+        self.student['accommodation'].addBedTicket(bedticket)
 
     def test_student_payments(self):
