def test_serialize_date(self): now = dates.now().date() nowstr = now.isoformat() self.assertEqual(nowstr, dates.serialize_date(now))
def test_serialize_datetime_as_date(self): now = dates.now() self.assertTrue(isinstance(now, datetime.datetime)) nowstr = dates.serialize_date(now) self.assertEquals(nowstr, now.date().isoformat())
def to_dict(self): if self.precision == 'day': return dates.serialize_date(self.value) return super(DateWithPrecision, self).to_dict()