Index: main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/tests/test_browser.py
===================================================================
--- main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/tests/test_browser.py	(revision 16926)
+++ main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/tests/test_browser.py	(revision 16928)
@@ -105,4 +105,18 @@
         self.tpucontainer.enddate = datetime.datetime.now(pytz.utc) + delta
 
+        # Add utp applicants container
+        self.utpcontainer = ApplicantsContainer()
+        self.utpcontainer.mode = 'create'
+        self.utpcontainer.code = u'utp%s' % session
+        self.utpcontainer.prefix = u'utp'
+        self.utpcontainer.application_category = u'basic'
+        self.utpcontainer.year = session
+        self.utpcontainer.application_fee = 300.0
+        self.utpcontainer.title = u'This is the utp%s container' % session
+        self.app['applicants'][self.utpcontainer.code] = self.utpcontainer
+        delta = datetime.timedelta(days=10)
+        self.utpcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
+        self.utpcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
+
         # Populate university
         self.certificate = createObject('waeup.Certificate')
@@ -150,4 +164,17 @@
             self.app['applicants'][self.tpucontainer.code][
             self.tpuapplicant.application_number]).setPassword('apwd')
+
+        utpapplicant = createObject(u'waeup.Applicant')
+        utpapplicant.firstname = u'Michelle'
+        utpapplicant.lastname = u'Obama'
+        self.app['applicants'][self.utpcontainer.code].addApplicant(utpapplicant)
+        self.utpapplication_number = utpapplicant.application_number
+        self.utpapplicant = self.app['applicants'][self.utpcontainer.code][
+            self.utpapplication_number]
+        self.utpapplicant_path = ('http://localhost/app/applicants/utp%s/%s'
+            % (session, self.utpapplication_number))
+        IUserAccount(
+            self.app['applicants'][self.utpcontainer.code][
+            self.utpapplicant.application_number]).setPassword('apwd')
 
         self.browser = Browser()
@@ -271,2 +298,83 @@
         self.assertEqual(self.tpuapplicant.state, 'submitted')
         return
+
+    def test_final_submit_utp(self):
+        # Create BED certificate
+        certificate1 = createObject('waeup.Certificate')
+        certificate1.application_category = 'basic'
+        certificate1.code = 'BEDCERT1'
+        certificate1.title = 'BEDCert1'
+        certificate1.start_level = 100
+        certificate1.end_level = 500
+        certificate1.study_mode = u'nce_ft'
+        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
+            certificate1)
+        IWorkflowState(self.utpapplicant).setState('paid')
+        self.browser.open(self.login_path)
+        self.browser.getControl(
+            name="form.login").value = self.utpapplicant.applicant_id
+        self.browser.getControl(name="form.password").value = 'apwd'
+        self.browser.getControl("Login").click()
+        self.browser.open(self.utpapplicant_path + '/edit')
+        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
+        self.browser.getControl(name="form.school_utp").value = ['utp0010']
+        self.browser.getControl(name="form.subj_comb").value = ['BEDCERT1']
+        image = open(SAMPLE_IMAGE, 'rb')
+        ctrl = self.browser.getControl(name='form.passport')
+        file_ctrl = ctrl.mech_control
+        file_ctrl.add_file(image, filename='myphoto.jpg')
+        self.browser.getControl(name="confirm_passport").value = True
+        self.browser.getControl("Save").click()
+        self.browser.getControl("Finally Submit").click()
+        self.assertTrue(
+            'Application submitted' in self.browser.contents)
+        # Create 10 applicants who already selected utp0010
+        for i in range(1,11):
+            dummy = createObject(u'waeup.Applicant')
+            dummy.firstname = u'John'
+            dummy.lastname = u'Doe %s' %i
+            dummy.school_utp = 'utp0010'
+            self.app['applicants'][
+                self.utpcontainer.code].addApplicant(dummy)
+            IWorkflowState(dummy).setState('submitted')
+        IWorkflowState(self.utpapplicant).setState('paid')
+        self.utpapplicant.locked = False
+        self.browser.open(self.utpapplicant_path + '/edit')
+        self.browser.getControl(name="form.school_utp").value = ['utp0010']
+        self.browser.getControl("Finally Submit").click()
+        self.assertTrue("Maximum number of applications per school exceeded."
+            in self.browser.contents)
+        self.assertEqual(self.utpapplicant.state, 'paid')
+        # Create second certificate
+        certificate2 = createObject('waeup.Certificate')
+        certificate2.code = 'BEDCERT2'
+        certificate2.title = 'BEDCert2'
+        certificate2.application_category = 'basic'
+        certificate2.start_level = 100
+        certificate2.end_level = 500
+        certificate2.study_mode = u'nce_ft'
+        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
+            certificate2)
+        # Create one applicant with same subject and same school
+        dummy = createObject(u'waeup.Applicant')
+        dummy.firstname = u'John'
+        dummy.lastname = u'Doe %s' %i
+        dummy.school_utp = 'utp0012'
+        dummy.subj_comb = certificate1
+        self.app['applicants'][
+            self.utpcontainer.code].addApplicant(dummy)
+        IWorkflowState(dummy).setState('submitted')
+        self.browser.open(self.utpapplicant_path + '/edit')
+        self.browser.getControl(name="form.school_utp").value = ['utp0012']
+        self.browser.getControl(name="form.subj_comb").value = ['BEDCERT1']
+        self.browser.getControl("Finally Submit").click()
+        self.assertTrue("Maximum number of applications per school exceeded."
+            in self.browser.contents)
+        # Same school with another subj_comb can be submitted
+        self.assertEqual(self.utpapplicant.state, 'paid')
+        self.browser.open(self.utpapplicant_path + '/edit')
+        self.browser.getControl(name="form.school_utp").value = ['utp0012']
+        self.browser.getControl(name="form.subj_comb").value = ['BEDCERT2']
+        self.browser.getControl("Finally Submit").click()
+        self.assertEqual(self.utpapplicant.state, 'submitted')
+        return
