def test_to_day(self): expected_result = datetime.date(2017, 3, 3) result = util.to_day('2017-03-03') self.assertEqual(result, expected_result) result = util.to_day('2017-03-03 01:00:01', util.DATETIME_FORMAT) self.assertEqual(result, expected_result) result = util.to_day(datetime.datetime(2017, 3, 3, 1, 00, 1)) self.assertEqual(result, expected_result) result = util.to_day(datetime.date(2017, 3, 3)) self.assertEqual(result, expected_result) with self.assertRaises(ValueError): util.to_day(123456789) with self.assertRaises(ValueError): util.to_day('2017-03-03 invalid format')
def _format_data(self, start_date, end_date, **kwargs): data = format_request_data(**kwargs) data['start_date'] = to_day(start_date) data['end_date'] = to_day(end_date) return data