本文整理汇总了Python中ics.event.Event类的典型用法代码示例。如果您正苦于以下问题:Python Event类的具体用法?Python Event怎么用?Python Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Event类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_make_all_day
def test_make_all_day(self):
e = Event(begin=0, end=20)
begin = e.begin
e.make_all_day()
self.assertEqual(e.begin, begin)
self.assertEqual(e._end_time, None)
self.assertEqual(e._duration, None)
示例2: test_make_all_day
def test_make_all_day(self):
e = Event(begin=0, end=20)
begin = e.begin
e.make_all_day()
self.assertEqual(e.begin, begin.date())
self.assertEqual(e.end, begin.date())
self.assertEqual(e.duration, timedelta(1))
示例3: test_has_end
def test_has_end(self):
e = Event()
self.assertFalse(e.has_end())
e = Event(begin="1993/05/24", duration=10)
self.assertTrue(e.has_end())
e = Event(begin="1993/05/24", end="1999/10/11")
self.assertTrue(e.has_end())
e = Event(begin="1993/05/24")
e.make_all_day()
self.assertFalse(e.has_end())
示例4: test_all_day_outputs_dtstart_value_date
def test_all_day_outputs_dtstart_value_date(self):
"""All day events should output DTSTART using VALUE=DATE without
time and timezone in order to assume the user's current timezone
refs http://www.kanzaki.com/docs/ical/dtstart.html
http://www.kanzaki.com/docs/ical/date.html
"""
e = Event(begin="2015/12/21")
e.make_all_day()
# no time or tz specifier
self.assertIn('DTSTART;VALUE=DATE:20151221', str(e).splitlines())
示例5: test_event
def test_event(self):
e = Event(begin=0, end=20)
self.assertEqual(e.begin.timestamp, 0)
self.assertEqual(e.end.timestamp, 20)
self.assertTrue(e.has_end())
self.assertFalse(e.all_day)
f = Event(begin=10, end=30)
self.assertTrue(e < f)
self.assertTrue(e <= f)
self.assertTrue(f > e)
self.assertTrue(f >= e)
示例6: test_event
def test_event(self):
e = Event(begin=0, end=20)
self.assertEqual(e.begin, datetime.fromtimestamp(0, tz=tzutc))
self.assertEqual(e.end, datetime.fromtimestamp(20, tz=tzutc))
self.assertTrue(e.has_end())
self.assertFalse(e.all_day)
f = Event(begin=10, end=30)
self.assertTrue(e < f)
self.assertTrue(e <= f)
self.assertTrue(f > e)
self.assertTrue(f >= e)
示例7: test_init
def test_init(self):
e = Event()
self.assertEqual(e.duration, None)
self.assertEqual(e.end, None)
self.assertFalse(e._has_duration())
self.assertFalse(e._has_end())
self.assertEqual(e.begin, None)
self.assertNotEqual(e.uid, None)
self.assertEqual(e.description, None)
self.assertNotEqual(e.created, None)
self.assertEqual(e.location, None)
self.assertEqual(e.url, None)
示例8: test_make_all_day2
def test_make_all_day2(self):
e = Event(begin="1993/05/24")
begin = arrow.get("1993/05/24")
self.assertEqual(e._begin, begin)
self.assertEqual(e.begin, begin)
self.assertEqual(e._end_time, None)
self.assertEqual(e.end, begin)
e.make_all_day()
self.assertEqual(e._begin, begin)
self.assertEqual(e.begin, begin)
self.assertEqual(e._begin_precision, "day")
self.assertEqual(e._end_time, None)
self.assertEqual(e.end, arrow.get("1993/05/25"))
示例9: test_join_intersected
def test_join_intersected(self):
# intersected events
event_a = Event(name='Test #1', begin=dt(2016, 6, 10, 20, 10), duration=td(minutes=30))
event_b = Event(name='Test #2', begin=dt(2016, 6, 10, 20, 30), duration=td(minutes=30))
assert event_a.join(event_b).time_equals(Event(name=None, begin=event_a.begin, end=event_b.end))
assert event_b.join(event_a).time_equals(Event(name=None, begin=event_a.begin, end=event_b.end))
event_a = Event(name='Test #1', begin=dt(2016, 6, 10, 20, 30), duration=td(minutes=30))
event_b = Event(name='Test #2', begin=dt(2016, 6, 10, 20, 10), duration=td(minutes=30))
assert event_a.join(event_b).time_equals(Event(name=None, begin=event_b.begin, end=event_a.end))
assert event_b.join(event_a).time_equals(Event(name=None, begin=event_b.begin, end=event_a.end))
示例10: test_intersects_included
def test_intersects_included(self):
# included events
event_a = Event(name='Test #1', begin=dt(2016, 6, 10, 20, 00), duration=td(minutes=60))
event_b = Event(name='Test #2', begin=dt(2016, 6, 10, 20, 10), duration=td(minutes=30))
assert event_a.intersects(event_b)
assert event_b.intersects(event_a)
event_a = Event(name='Test #1', begin=dt(2016, 6, 10, 20, 10), duration=td(minutes=30))
event_b = Event(name='Test #2', begin=dt(2016, 6, 10, 20, 00), duration=td(minutes=60))
assert event_a.intersects(event_b)
assert event_b.intersects(event_a)
示例11: test_duration
def test_duration(self):
e = Event()
self.assertIsNone(e.duration)
e1 = Event(begin="1993/05/24")
e1.make_all_day()
self.assertEqual(e1.duration, timedelta(days=1))
e2 = Event(begin="1993/05/24", end="1993/05/30")
self.assertEqual(e2.duration, timedelta(days=6))
e3 = Event(begin="1993/05/24", duration=timedelta(minutes=1))
self.assertEqual(e3.duration, timedelta(minutes=1))
e4 = Event(begin="1993/05/24")
self.assertEqual(e4.duration, timedelta(seconds=1))
e5 = Event(begin="1993/05/24")
e5.duration = {'days': 6, 'hours': 2}
self.assertEqual(e5.end, arrow.get("1993/05/30T02:00"))
self.assertEqual(e5.duration, timedelta(hours=146))
示例12: test_duration
def test_duration(self):
e = Event()
self.assertIsNone(e.duration)
birthday = Event(begin="1993/05/24")
self.assertEqual(birthday.duration, timedelta(days=1))
vacation = Event(begin="1993/05/24", end="1993/05/30")
self.assertEqual(vacation.duration, timedelta(days=7))
e3 = Event(begin=datetime(1993, 5, 24, 12),
duration=timedelta(minutes=1))
self.assertEqual(e3.duration, timedelta(minutes=1))
e4 = Event(begin=datetime(1993, 5, 24, 12))
self.assertEqual(e4.duration, timedelta(seconds=1))
e5 = Event(begin=datetime(1993, 5, 24, 12))
e5.duration = {'days': 6, 'hours': 2}
self.assertEqual(e5.end, parse_date_or_datetime("1993/05/30T14:00"))
self.assertEqual(e5.duration, timedelta(hours=146))
示例13: test_join_disjoined
def test_join_disjoined(self):
# disjoined events
event_a = Event(name='Test #1', begin=dt(2016, 6, 10, 20, 10), duration=td(minutes=20))
event_b = Event(name='Test #2', begin=dt(2016, 6, 10, 20, 50), duration=td(minutes=20))
with pytest.raises(ValueError):
event_a.join(event_b)
with pytest.raises(ValueError):
event_b.join(event_a)
示例14: test_escapte_output
def test_escapte_output(self):
e = Event()
e.name = "Hello, with \\ spechial; chars and \n newlines"
e.location = "Here; too"
e.description = "Every\nwhere ! Yes, yes !"
e.created = arrow.Arrow(2013, 1, 1)
e.uid = "empty-uid"
eq = CRLF.join(("BEGIN:VEVENT",
"DTSTAMP:20130101T000000Z",
"SUMMARY:Hello\\, with \\\\ spechial\\; chars and \\n newlines",
"DESCRIPTION:Every\\nwhere ! Yes\\, yes !",
"LOCATION:Here\\; too",
"UID:empty-uid",
"END:VEVENT"))
self.assertEqual(str(e), eq)
示例15: test_escape_output
def test_escape_output(self):
e = Event()
e.name = "Hello, with \\ spechial; chars and \n newlines"
e.location = "Here; too"
e.description = "Every\nwhere ! Yes, yes !"
e.created = datetime(2013, 1, 1, tzinfo=tzutc)
e.uid = "empty-uid"
output = str(e).splitlines()
self.assertEqual(output[0], "BEGIN:VEVENT")
self.assertEqual(output[-1], "END:VEVENT")
eq = set(("DTSTAMP:20130101T000000Z",
"SUMMARY:Hello\\, with \\\\ spechial\\; chars and \\n newlines",
"DESCRIPTION:Every\\nwhere ! Yes\\, yes !",
"LOCATION:Here\\; too",
"UID:empty-uid"))
self.assertEqual(set(output[1:-1]), eq)