Ignore:
Timestamp:
29 Jan 2012, 08:29:43 (13 years ago)
Author:
Henrik Bettermann
Message:

Fix logic. entryExists must return True or False, nothing else.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/batching.py

    r7532 r7534  
    268268        return self.getParent(row, site) is not None
    269269
     270
    270271    def entryExists(self, row, site):
     272        return self.getEntry(row, site) is not None
     273
     274    def getEntry(self, row, site):
    271275        student = self.getParent(row, site)
    272         if not student:
    273             return None
    274         if 'studycourse' in student:
    275             return student
    276         return None
    277 
    278     def getEntry(self, row, site):
    279         student = self.entryExists(row, site)
    280276        if not student:
    281277            return None
     
    301297        # We have to check if current_level is in range of certificate.
    302298        # This is not done by the converter.
    303         certificate = conv_dict['certificate']
    304         start_level = certificate.start_level
    305         end_level = certificate.end_level
    306         if conv_dict['current_level'] < start_level or \
    307             conv_dict['current_level'] > end_level:
    308             errs.append(('current_level','not in range'))
     299        if conv_dict.has_key('certificate'):
     300          certificate = conv_dict['certificate']
     301          start_level = certificate.start_level
     302          end_level = certificate.end_level
     303          if conv_dict['current_level'] < start_level or \
     304              conv_dict['current_level'] > end_level:
     305              errs.append(('current_level','not in range'))
    309306        return errs, inv_errs, conv_dict
    310307
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_batching.py

    r7531 r7534  
    132132
    133133    def test_entryExists(self):
    134         self.assertFalse(self.importer.entryExists(
    135             dict(student_id='ID_NONE'), self.app))
    136         student = self.importer.getEntry(
    137             dict(student_id=self.student.student_id), self.app)
    138         self.assertEqual(student.reg_number, u'123')
     134        assert self.importer.entryExists(
     135            dict(student_id='ID_NONE'), self.app) is False
     136        assert self.importer.entryExists(
     137            dict(reg_number='123'), self.app) is True
    139138
    140139    def test_getParent(self):
     
    267266    def test_entryExists(self):
    268267        assert self.importer.entryExists(
    269             dict(reg_number='REG_NONE'), self.app) is None
    270         student = self.importer.entryExists(dict(reg_number='1'), self.app)
    271         self.assertEqual(student.reg_number, u'1')
     268            dict(reg_number='REG_NONE'), self.app) is False
     269        assert self.importer.entryExists(
     270            dict(reg_number='1'), self.app) is True
    272271
    273272    def test_getEntry(self):
    274         studycourse = self.importer.getEntry(dict(reg_number='1'), self.app)
    275         student = studycourse.__parent__
    276         s_id = student.student_id
    277         assert studycourse is self.app['students'][s_id]['studycourse']
     273        student = self.importer.getEntry(
     274            dict(reg_number='1'), self.app).__parent__
     275        self.assertEqual(student.reg_number,'1')
    278276
    279277    def test_import(self):
Note: See TracChangeset for help on using the changeset viewer.