当前位置: 首页>>代码示例>>Python>>正文


Python event.Event类代码示例

本文整理汇总了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)
开发者ID:PretentiousPotatoPeeler,项目名称:ics.py,代码行数:7,代码来源:event.py

示例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))
开发者ID:jammon,项目名称:ics.py,代码行数:7,代码来源:event.py

示例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())
开发者ID:PretentiousPotatoPeeler,项目名称:ics.py,代码行数:10,代码来源:event.py

示例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())
开发者ID:m42e,项目名称:ics.py,代码行数:11,代码来源:event.py

示例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)
开发者ID:PretentiousPotatoPeeler,项目名称:ics.py,代码行数:12,代码来源:event.py

示例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)
开发者ID:jammon,项目名称:ics.py,代码行数:12,代码来源:event.py

示例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)
开发者ID:jammon,项目名称:ics.py,代码行数:13,代码来源:event.py

示例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"))
开发者ID:C4ptainCrunch,项目名称:ics.py,代码行数:18,代码来源:event.py

示例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))
开发者ID:C4ptainCrunch,项目名称:ics.py,代码行数:11,代码来源:event.py

示例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)
开发者ID:C4ptainCrunch,项目名称:ics.py,代码行数:11,代码来源:event.py

示例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))
开发者ID:PretentiousPotatoPeeler,项目名称:ics.py,代码行数:21,代码来源:event.py

示例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))
开发者ID:jammon,项目名称:ics.py,代码行数:21,代码来源:event.py

示例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)
开发者ID:C4ptainCrunch,项目名称:ics.py,代码行数:8,代码来源:event.py

示例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)
开发者ID:PretentiousPotatoPeeler,项目名称:ics.py,代码行数:17,代码来源:event.py

示例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)
开发者ID:jammon,项目名称:ics.py,代码行数:18,代码来源:event.py


注:本文中的ics.event.Event类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。