def testSerialize(self): date = datetime.date(2013, 2, 3) assert parameter[datetime.date]._p.to_str(date) == "2013-02-03" assert YearParameter()._p.to_str(date) == "2013" assert MonthParameter()._p.to_str(date) == "2013-02" dt = datetime.datetime(2013, 2, 3, 4, 5) assert parameters.DateHourParameter()._p.to_str(dt) == "2013-02-03T04"
def test_serialize(self): dh = parameters.DateHourParameter()._p.to_str( datetime.datetime(2013, 2, 1, 18, 0, 0)) assert dh == "2013-02-01T18"
def test_date_to_dh(self): date = parameters.DateHourParameter()._p.normalize( datetime.date(2000, 1, 1)) assert date == datetime.datetime(2000, 1, 1, 0, tzinfo=utc)
def test_parse(self): dh = parameters.DateHourParameter()._p.parse_from_str("2013-02-01T18") assert dh == datetime.datetime(2013, 2, 1, 18, 0, 0, tzinfo=utc)
class DateHourTask(TTask): dh = parameters.DateHourParameter()