Ignore:
Timestamp:
27 Sep 2011, 08:07:54 (13 years ago)
Author:
Henrik Bettermann
Message:

We should be very strict when importing dates and allow only one import format: YYYY-MM-DD.

Overwrite the DateWidget? by the FormattedDateWidget?, already defined in the widgets package, to generally bypass Python's parseDatetimetz module which is used by the original DateWidget?. parseDatetimetz is too dangerous when used in importers.

File:
1 edited

Legend:

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

    r6743 r6819  
    250250        contact = Contact()
    251251        converter = IObjectConverter(IContact) # a converter to IContact
    252         err, inv_err, data = converter.fromStringDict(
    253             dict(birthday='1945/12/23'), contact)
     252
     253        # The input format for dates: YYYY-MM-DD
     254        err, inv_err, data = converter.fromStringDict(
     255            dict(birthday='1945-12-23'), contact)
    254256        assert data['birthday'] == datetime.date(1945, 12, 23)
    255257        assert isinstance(data['birthday'], datetime.date)
    256258
    257259        err, inv_err, data = converter.fromStringDict(
    258             dict(birthday='1945/23/12'), contact)
    259         assert data['birthday'] == datetime.date(1945, 12, 23)
    260 
    261         # The preferred input format for dates: YYYY-MM-DD
    262         err, inv_err, data = converter.fromStringDict(
    263             dict(birthday='1945-12-23'), contact)
    264         assert data['birthday'] == datetime.date(1945, 12, 23)
     260            dict(birthday='1945-23-12'), contact)
     261        #import pdb; pdb.set_trace()
     262        #assert data['birthday'] == datetime.date(1945, 12, 23)
     263        assert err[0][1] =='Invalid datetime data'
    265264
    266265        # '08' is not interpreted as octal number
Note: See TracChangeset for help on using the changeset viewer.