Ignore:
Timestamp:
28 Aug 2012, 08:14:49 (12 years ago)
Author:
Henrik Bettermann
Message:

Fix tests. Do not use fixed year numbers which will be of range in a few years.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_applicantcopier.py

    r8843 r9116  
    2121import os
    2222import grok
     23from datetime import datetime
    2324from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    2425from zope.event import notify
     
    2829from waeup.kofa.interfaces import IExtFileStore, IFileStoreNameChooser
    2930from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
     31
     32session = datetime.now().year - 2
    3033
    3134class ApplicantCopierFunctionalTests(ApplicantsFullSetup):
     
    118121        # Has the student studycourse the correct attributes?
    119122        self.assertEqual(student['studycourse'].certificate.code, 'CERT1')
    120         self.assertEqual(student['studycourse'].entry_session, 2009)
     123        self.assertEqual(student['studycourse'].entry_session, session)
    121124        self.assertEqual(student['studycourse'].entry_mode, 'ug_ft')
    122         self.assertEqual(student['studycourse'].current_session, 2009)
     125        self.assertEqual(student['studycourse'].current_session, session)
    123126        self.assertEqual(student['studycourse'].current_level, 100)
    124127
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r9055 r9116  
    2323import tempfile
    2424import grok
     25from datetime import datetime
    2526from StringIO import StringIO
    2627from datetime import datetime, date, timedelta
     
    4647PH_LEN = 2059  # Length of placeholder file
    4748
     49session_1 = datetime.now().year - 2
     50container_name_1 = u'app%s' % session_1
     51session_2 = datetime.now().year - 1
     52container_name_2 = u'app%s' % session_2
     53
    4854class ApplicantsFullSetup(FunctionalTestCase):
    4955    # A test case that only contains a setup and teardown
     
    8086        self.manage_root_path = self.root_path + '/@@manage'
    8187        self.add_container_path = self.root_path + '/@@add'
    82         self.container_path = 'http://localhost/app/applicants/app2009'
     88        self.container_path = 'http://localhost/app/applicants/%s' % container_name_1
    8389        self.manage_container_path = self.container_path + '/@@manage'
    8490
    8591        # Add an applicants container
    8692        applicantscontainer = ApplicantsContainer()
    87         applicantscontainer.code = u'app2009'
     93        applicantscontainer.code = container_name_1
    8894        applicantscontainer.prefix = 'app'
    89         applicantscontainer.year = 2009
    90         applicantscontainer.title = u'This is the app2009 container'
     95        applicantscontainer.year = session_1
     96        applicantscontainer.title = u'This is the %s container' % container_name_1
    9197        applicantscontainer.application_category = 'basic'
    9298        applicantscontainer.mode = 'create'
     
    95101        applicantscontainer.startdate = datetime.now(pytz.utc) - delta
    96102        applicantscontainer.enddate = datetime.now(pytz.utc) + delta
    97         self.app['applicants']['app2009'] = applicantscontainer
    98         self.applicantscontainer = self.app['applicants']['app2009']
     103        self.app['applicants'][container_name_1] = applicantscontainer
     104        self.applicantscontainer = self.app['applicants'][container_name_1]
    99105
    100106        # Populate university
     
    135141        self.applicant.reg_number = u'1234'
    136142        self.applicant.course1 = certificate
    137         app['applicants']['app2009'].addApplicant(self.applicant)
     143        app['applicants'][container_name_1].addApplicant(self.applicant)
    138144        IUserAccount(
    139             self.app['applicants']['app2009'][
     145            self.app['applicants'][container_name_1][
    140146            self.applicant.application_number]).setPassword('apwd')
    141147        self.manage_path = 'http://localhost/app/applicants/%s/%s/%s' % (
    142             'app2009', self.applicant.application_number, 'manage')
     148            container_name_1, self.applicant.application_number, 'manage')
    143149        self.edit_path = 'http://localhost/app/applicants/%s/%s/%s' % (
    144             'app2009', self.applicant.application_number, 'edit')
     150            container_name_1, self.applicant.application_number, 'edit')
    145151        self.view_path = 'http://localhost/app/applicants/%s/%s' % (
    146             'app2009', self.applicant.application_number)
     152            container_name_1, self.applicant.application_number)
    147153
    148154    def login(self):
     
    303309            'There were errors' in self.browser.contents)
    304310        self.browser.getControl(name="form.prefix").value = ['app']
    305         self.browser.getControl(name="form.year").value = ['2010']
     311        self.browser.getControl(name="form.year").value = [str(session_2)]
    306312        self.browser.getControl(name="form.mode").value = ['create']
    307313        self.browser.getControl(
     
    317323        self.browser.open(self.add_container_path)
    318324        self.browser.getControl(name="form.prefix").value = ['app']
    319         self.browser.getControl(name="form.year").value = ['2010']
     325        self.browser.getControl(name="form.year").value = [str(session_2)]
    320326        self.browser.getControl(name="form.mode").value = ['create']
    321327        self.browser.getControl(
     
    326332        self.browser.open(self.manage_root_path)
    327333        ctrl = self.browser.getControl(name='val_id')
    328         ctrl.getControl(value='app2010').selected = True
     334        ctrl.getControl(value=container_name_2).selected = True
    329335        self.browser.getControl("Remove selected", index=0).click()
    330336        self.assertTrue('Successfully removed:' in self.browser.contents)
    331337        self.browser.open(self.add_container_path)
    332338        self.browser.getControl(name="form.prefix").value = ['app']
    333         self.browser.getControl(name="form.year").value = ['2010']
     339        self.browser.getControl(name="form.year").value = [str(session_2)]
    334340        self.browser.getControl(name="form.mode").value = ['create']
    335341        #self.browser.getControl(name="form.ac_prefix").value = ['APP']
     
    337343            name="form.application_category").value = ['basic']
    338344        self.browser.getControl("Add applicants container").click()
    339         del self.app['applicants']['app2010']
     345        del self.app['applicants'][container_name_2]
    340346        ctrl = self.browser.getControl(name='val_id')
    341         ctrl.getControl(value='app2010').selected = True
     347        ctrl.getControl(value=container_name_2).selected = True
    342348        self.browser.getControl("Remove selected", index=0).click()
    343349        self.assertMatches('...Could not delete...', self.browser.contents)
     
    711717            in self.browser.contents)
    712718        configuration = SessionConfiguration()
    713         configuration.academic_session = 2009
     719        configuration.academic_session = session_1
    714720        configuration.application_fee = 200.0
    715721        self.app['configuration'].addSessionConfiguration(configuration)
     
    739745        payment_id = self.applicant.keys()[0]
    740746        payment = self.applicant[payment_id]
    741         self.assertEqual(payment.p_item,'This is the app2009 container')
    742         self.assertEqual(payment.p_session,2009)
     747        self.assertEqual(payment.p_item,'This is the %s container' % container_name_1)
     748        self.assertEqual(payment.p_session, session_1)
    743749        self.assertEqual(payment.p_category,'application')
    744750        self.assertEqual(payment.amount_auth,200.0)
     
    989995            in self.browser.contents)
    990996        #IUserAccount(
    991         #    self.app['applicants']['app2009'][
     997        #    self.app['applicants'][container_name_1][
    992998        #    self.applicant.application_number]).context.password = None
    993999        # Even without unsetting the password we can re-register if state
Note: See TracChangeset for help on using the changeset viewer.