Ignore:
Timestamp:
9 Apr 2012, 16:35:24 (13 years ago)
Author:
Henrik Bettermann
Message:

Add tests for changes in previous revision and remove additional bug found with these tests.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r8081 r8082  
    225225                self.flash(_('Empty search string'))
    226226            return
     227        if self.searchtype == 'current_session':
     228            try:
     229                self.searchterm = int(self.searchterm)
     230            except ValueError:
     231                self.flash('Only year dates allowed (e.g. 2011).')
     232                return
    227233        if not 'entries' in form:
    228234            self.hitlist = search(query=self.searchterm,
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r8039 r8082  
    279279        self.browser.getControl("Search").click()
    280280        self.assertTrue('Anna Tester' in self.browser.contents)
     281        # Session fileds require integer values
     282        self.browser.open(self.container_path)
     283        self.browser.getControl(name="searchtype").value = ['current_session']
     284        self.browser.getControl(name="searchterm").value = '2004/2005'
     285        self.browser.getControl("Search").click()
     286        self.assertTrue('Only year dates allowed' in self.browser.contents)
     287        self.browser.open(self.manage_container_path)
     288        self.browser.getControl(name="searchtype").value = ['current_session']
     289        self.browser.getControl(name="searchterm").value = '2004/2005'
     290        self.browser.getControl("Search").click()
     291        self.assertTrue('Only year dates allowed' in self.browser.contents)
    281292
    282293        # We can find a student in a certain study_mode
     
    338349        self.assertTrue('Anna Tester' in self.browser.contents)
    339350        # The old searchterm will be used again
     351        self.browser.getControl("Search").click()
     352        self.assertTrue('Anna Tester' in self.browser.contents)
     353
     354        # The catalog is informed when studycourse objects have been
     355        # edited
     356        self.browser.open(self.studycourse_path + '/manage')
     357        self.browser.getControl(name="form.current_session").value = ['2010']
     358        self.browser.getControl(name="form.entry_session").value = ['2010']
     359        self.browser.getControl(name="form.entry_mode").value = ['ug_ft']
     360        self.browser.getControl("Save").click()
     361
     362        # We can find the student in the new session
     363        self.browser.open(self.manage_container_path)
     364        self.browser.getControl(name="searchtype").value = ['current_session']
     365        self.browser.getControl(name="searchterm").value = '2010'
    340366        self.browser.getControl("Search").click()
    341367        self.assertTrue('Anna Tester' in self.browser.contents)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_catalog.py

    r7811 r8082  
    6363        self.student = self.app['students'][self.student_id]
    6464        self.student['studycourse'].certificate = self.certificate
     65        self.student['studycourse'].current_session = 2010
    6566        # Update the students_catalog
    6667        notify(grok.ObjectModifiedEvent(self.student))
     
    128129        assert results[0] is self.app['students'][self.student_id]
    129130
     131    def test_search_by_session(self):
     132        # We can find a student in a certain session
     133        cat = queryUtility(ICatalog, name='students_catalog')
     134        results = cat.searchResults(current_session=(2010,2010))
     135        results = [x for x in results] # Turn results generator into list
     136        assert len(results) == 1
     137        assert results[0] is self.app['students'][self.student_id]
     138
    130139class CourseTicketCatalogTests(CatalogTestSetup):
    131140
Note: See TracChangeset for help on using the changeset viewer.