Ignore:
Timestamp:
19 Apr 2012, 13:05:07 (13 years ago)
Author:
uli
Message:

Test DELETION_MARKER and IGNORE_MARKER functionality of converters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_converters.py

    r8213 r8216  
    3535from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
    3636from waeup.kofa.interfaces import (
    37     SimpleKofaVocabulary, SubjectSource, GradeSource, IFieldConverter)
     37    SimpleKofaVocabulary, SubjectSource, GradeSource, IFieldConverter,
     38    DELETION_MARKER, IGNORE_MARKER)
    3839from waeup.kofa.schoolgrades import ResultEntryField
    3940from waeup.kofa.university import Faculty
     
    403404        self.assertEqual(result_grades[0].grade, g_val1)
    404405        return
     406
     407    def test_ignore_values(self):
     408        # in update mode we ignore marked values
     409        converter = IObjectConverter(IContact)
     410        err, inv_err, data = converter.fromStringDict(
     411            {"friends": IGNORE_MARKER},
     412            Contact(),
     413            mode='update')
     414        # the ignored key/value are not part of the result
     415        self.assertEqual(data, {})
     416        return
     417
     418    def test_delete_values(self):
     419        # in update mode we delete values marked accordingly
     420        # 'deleting' means setting to missing_value or to default if required.
     421        converter = IObjectConverter(IContact)
     422        err, inv_err, data = converter.fromStringDict(
     423            {"grades": DELETION_MARKER,
     424             "friends": DELETION_MARKER},
     425            'contact', mode='update')
     426        # grades are about to be set to default, friends to None
     427        self.assertEqual(data, {'grades': [], 'friends': None})
     428        return
Note: See TracChangeset for help on using the changeset viewer.