本文整理汇总了Python中models.event.Event.withinDays方法的典型用法代码示例。如果您正苦于以下问题:Python Event.withinDays方法的具体用法?Python Event.withinDays怎么用?Python Event.withinDays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.event.Event
的用法示例。
在下文中一共展示了Event.withinDays方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestEventManipulator
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import withinDays [as 别名]
class TestEventManipulator(unittest2.TestCase):
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
self.future_event = Event(
id="2011ct",
end_date=datetime.datetime.today() + datetime.timedelta(days=5),
event_short="ct",
event_type="Regional",
first_eid="5561",
name="Northeast Utilities FIRST Connecticut Regional",
start_date=datetime.datetime.today() + datetime.timedelta(days=1),
year=2011,
venue_address="Connecticut Convention Center\r\n100 Columbus Blvd\r\nHartford, CT 06103\r\nUSA",
website="http://www.ctfirst.org/ctr",
)
self.present_event = Event(
id="2011ct",
end_date=datetime.datetime.today() + datetime.timedelta(days=1),
event_short="ct",
event_type="Regional",
first_eid="5561",
name="Northeast Utilities FIRST Connecticut Regional",
start_date=datetime.datetime.today() - datetime.timedelta(days=2),
year=2011,
venue_address="Connecticut Convention Center\r\n100 Columbus Blvd\r\nHartford, CT 06103\r\nUSA",
website="http://www.ctfirst.org/ctr",
)
self.past_event = Event(
id="2011ct",
end_date=datetime.datetime.today() - datetime.timedelta(days=1),
event_short="ct",
event_type="Regional",
first_eid="5561",
name="Northeast Utilities FIRST Connecticut Regional",
start_date=datetime.datetime.today() - datetime.timedelta(days=5),
year=2011,
venue_address="Connecticut Convention Center\r\n100 Columbus Blvd\r\nHartford, CT 06103\r\nUSA",
website="http://www.ctfirst.org/ctr",
)
def tearDown(self):
self.testbed.deactivate()
def test_datesFuture(self):
self.assertFalse(self.future_event.now)
self.assertTrue(self.future_event.within_a_day)
self.assertFalse(self.future_event.withinDays(0, 3))
self.assertTrue(self.future_event.withinDays(-3, 0))
def test_datesPast(self):
self.assertFalse(self.past_event.now)
self.assertTrue(self.past_event.within_a_day)
self.assertTrue(self.past_event.withinDays(0, 3))
self.assertFalse(self.past_event.withinDays(-3, 0))
def test_datesPresent(self):
self.assertTrue(self.present_event.now)
self.assertTrue(self.present_event.withinDays(-1, 1))