本文整理汇总了Python中dimagi.utils.dates.DateSpan.get_validation_reason方法的典型用法代码示例。如果您正苦于以下问题:Python DateSpan.get_validation_reason方法的具体用法?Python DateSpan.get_validation_reason怎么用?Python DateSpan.get_validation_reason使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dimagi.utils.dates.DateSpan
的用法示例。
在下文中一共展示了DateSpan.get_validation_reason方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_end_before_start
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import get_validation_reason [as 别名]
def test_end_before_start(self):
startdate = datetime(2015, 02, 01)
enddate = datetime(2015, 01, 01)
datespan = DateSpan(startdate, enddate)
self.assertFalse(datespan.is_valid())
self.assertEqual(datespan.get_validation_reason(),
"You can't have an end date of %s after start date of %s" % (enddate, startdate))
示例2: test_datespan_too_long
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import get_validation_reason [as 别名]
def test_datespan_too_long(self):
datespan = DateSpan(datetime(2015, 01, 01), datetime(2015, 07, 01), max_days=90)
self.assertFalse(datespan.is_valid())
self.assertEqual(datespan.get_validation_reason(),
"You are limited to a span of 90 days, but this date range spans 181 days")
示例3: test_wrong_century
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import get_validation_reason [as 别名]
def test_wrong_century(self):
datespan = DateSpan(datetime(1815, 01, 01), datetime(1815, 02, 01))
self.assertFalse(datespan.is_valid())
self.assertEqual(datespan.get_validation_reason(), "You can't use dates earlier than the year 1900")
示例4: test_date_missing
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import get_validation_reason [as 别名]
def test_date_missing(self):
datespan = DateSpan(datetime(2015, 01, 01), None)
self.assertFalse(datespan.is_valid())
self.assertEqual(datespan.get_validation_reason(), "You have to specify both dates!")
示例5: test_ok
# 需要导入模块: from dimagi.utils.dates import DateSpan [as 别名]
# 或者: from dimagi.utils.dates.DateSpan import get_validation_reason [as 别名]
def test_ok(self):
datespan = DateSpan(datetime(2015, 01, 01), datetime(2015, 02, 01))
self.assertTrue(datespan.is_valid())
self.assertEqual(datespan.get_validation_reason(), "")