Index: main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_browser.py
===================================================================
--- main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_browser.py	(revision 17611)
+++ main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_browser.py	(revision 17866)
@@ -456,4 +456,74 @@
         return
 
+    def test_final_clearance(self):
+        self.app['users'].addUser('mrbursary', SECRET)
+        self.app['users']['mrbursary'].email = 'mrbursary@foo.ng'
+        self.app['users']['mrbursary'].title = u'Carl Pitter'
+        # Clearance officers needs to get
+        # the StudentsOfficer site role
+        prmglobal = IPrincipalRoleManager(self.app)
+        prmglobal.assignRoleToPrincipal('waeup.StudentsOfficer', 'mrbursary')
+        # Assign BursaryOfficer role
+        prmglobal.assignRoleToPrincipal('waeup.BursaryOfficer', 'mrbursary')
+        # and FinalClearanceOfficer role
+        prmglobal.assignRoleToPrincipal(
+            'waeup.FinalClearanceOfficer', 'mrbursary')
+        # Login
+        self.browser.open(self.login_path)
+        self.browser.getControl(name="form.login").value = 'mrbursary'
+        self.browser.getControl(name="form.password").value = SECRET
+        self.browser.getControl("Login").click()
+        # BO can see his roles
+        self.browser.getLink("My Roles").click()
+        self.assertMatches(
+            '...<div>Bursary Officer</div>...',
+            self.browser.contents)
+        # BO can view student record
+        self.browser.open(self.student_path)
+        # BO can see clearance button ...
+        self.assertTrue(
+            'Clear student finally' in self.browser.contents)
+        # ... but not withdraw button
+        self.assertFalse(
+            'Withdraw final clearance' in self.browser.contents)
+        # BO can clear student
+        self.browser.getLink("Clear student finally").click()
+        self.assertTrue(
+            'Student has been finally cleared' in self.browser.contents)
+        # Name of BO and date have been stored
+        self.assertEqual(self.student.finally_cleared_by, 'Carl Pitter')
+        self.assertMatches(
+            '<YYYY-MM-DD hh:mm:ss>',
+            self.student.final_clearance_date.strftime(
+                "%Y-%m-%d %H:%M:%S"))
+        # BO can't see clearance button ...
+        self.assertFalse(
+            'Clear student finally' in self.browser.contents)
+        # ... but withdraw button and can withdraw clearance
+        self.browser.getLink("Withdraw final clearance").click()
+        self.assertTrue(
+            'Final clearance withdrawn' in self.browser.contents)
+        # Name of BO and date have been deleted
+        self.assertEqual(self.student.finally_cleared_by, None)
+        self.assertEqual(self.student.final_clearance_date, None)
+        # Clearance is logged
+        logfile = os.path.join(
+            self.app['datacenter'].storage, 'logs', 'students.log')
+        logcontent = open(logfile).read()
+        self.assertTrue(
+            'mrbursary - kofacustom.nigeria.students.browser.ClearStudentFinally'
+            ' - K1000000 - finally cleared' in logcontent)
+        self.assertTrue(
+            'mrbursary - kofacustom.nigeria.students.browser.WithdrawFinalClearance'
+            ' - K1000000 - final clearance withdrawn' in logcontent)
+        # Clearance is also stored in the history
+        self.browser.open(self.history_path)
+        self.assertMatches(
+            '...2016-01-16 15:50:48 WAT - Finally cleared by Carl Pitter...',
+            self.browser.contents)
+        self.assertMatches(
+            '...2016-01-16 15:50:48 WAT - Final clearance withdrawn by Carl Pitter...',
+            self.browser.contents)
+
     def test_provisionally_cleared(self):
         # Students can edit clearance data
Index: main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_export.py
===================================================================
--- main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_export.py	(revision 17611)
+++ main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_export.py	(revision 17866)
@@ -71,4 +71,5 @@
             'emp2_position,emp2_reason,emp2_start,emp_end,emp_position,'
             'emp_reason,emp_start,employer,employer2,'
+            'final_clearance_date,finally_cleared_by,'
             'financial_clearance_date,financially_cleared_by,'
             'firstname,flash_notice,former_matric,'
@@ -87,5 +88,5 @@
             'current_level,current_session\r\nmy adm code,,,,'
             '"[(\'accounts\', \'A\')]",my clr code,1981-02-04#,,,'
-            'anna@sample.com,,,,,,,,,,,,,Anna,,,,,,"[(\'accounts\', \'A\')]"'
+            'anna@sample.com,,,,,,,,,,,,,,,Anna,,,,,,"[(\'accounts\', \'A\')]"'
             ',,,,,,,,,,,,,,,,Tester,,,234,M.,NG,,,,,,,,,,'
             '"Studentroad 21\nLagos 123456\n",,+234-123-12345#,,,123,,,,,'
