예제 #1
0
파일: event.py 프로젝트: jasonehines/ics.py
    def test_includes_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.includes(event_b)
        assert not event_b.includes(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 not event_a.includes(event_b)
        assert event_b.includes(event_a)
예제 #2
0
    def test_clone(self):
        c0 = Calendar()
        e = Event()
        t = Todo()
        c0.events.add(e)
        c0.todos.add(t)
        c1 = c0.clone()

        self.assertEqual(c0.events, c1.events)
        self.assertEqual(c0.todos, c1.todos)
        self.assertEqual(c0, c1)
예제 #3
0
파일: eventlist.py 프로젝트: davidjb/ics.py
    def test_getitem(self):

        l = EventList()
        t = arrow.now()

        e = Event("test", t.replace(seconds=-1), t.replace(seconds=+1))
        l.append(e)
        getitem = l.__getitem__(e.begin)
        getitem = l[e.begin]

        self.assertEqual([e], getitem)
예제 #4
0
파일: event.py 프로젝트: zuphilip/ics.py
    def equality(self):
        ev1 = Event(begin=datetime(2018, 6, 29, 5), end=datetime(2018, 6, 29, 7), name="my name")
        ev2 = ev1.clone()

        assert ev1 == ev2

        ev2.uid = "something else"
        assert ev1 == ev2

        ev2.name = "other name"
        assert ev1 != ev2
예제 #5
0
파일: eventlist.py 프로젝트: davidjb/ics.py
    def test_remove_duplicate_same(self):

        l = EventList()
        t = arrow.now()

        e = Event("t", t.replace(hours=-1), t.replace(hours=+1))
        l.append(e)
        l.append(e)
        l._remove_duplicates()

        self.assertEqual(1, len(l))
예제 #6
0
    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())
예제 #7
0
파일: timeline.py 프로젝트: tomschr/ics.py
    def test_included(self):

        c = Calendar()

        e = [
            Event(begin=datetime(2015, 10, 10)),
            Event(begin=datetime(2010, 10, 10)),
            Event(begin=datetime(2020, 10, 10)),
            Event(begin=datetime(2015, 1, 10)),
            Event(begin=datetime(2014, 1, 10), end=datetime(2018, 1, 10)),
        ]

        for ev in e:
            c.events.append(ev)

        included = list(c.timeline.included(
            (datetime(2013, 10, 10)),
            (datetime(2017, 10, 10))
        ))
        self.assertSequenceEqual(included, [e[3]] + [e[0]])
예제 #8
0
    def test_neq_len(self):
        c0, c1 = Calendar(), Calendar()
        e1 = Event()
        e2 = Event()

        c0.events.add(e1)
        c0.events.add(e2)

        c1.events.add(e1)

        self.assertNotEqual(c0, c1)

        t1 = Todo()
        t2 = Todo()

        c0.todos.add(t1)
        c0.todos.add(t2)

        c1.todos.add(t1)

        self.assertNotEqual(c0, c1)
예제 #9
0
파일: eventlist.py 프로젝트: davidjb/ics.py
    def test_raise(self):

        l = EventList()
        t = arrow.now()

        e = Event(begin=t.replace(hours=-1), end=t.replace(hours=+1))

        with self.assertRaises(ValueError):
            l[::'dne']
            l[e.begin::'cni']
            l[e.begin:e.end:'htob']
            l[:e.end:'nigeb']
예제 #10
0
파일: eventlist.py 프로젝트: davidjb/ics.py
    def test_add_(self):

        l0 = EventList()
        l1 = EventList()
        t = arrow.now()

        e = Event("t", t.replace(hours=-1), t.replace(hours=+1))
        l0.append(e)
        l1.append(e)
        l2 = l0 + l1

        self.assertEqual(1, len(l2))
예제 #11
0
파일: eventlist.py 프로젝트: davidjb/ics.py
    def test_evlist(self):

        l = EventList()
        t = self.time()

        self.assertEqual(len(l), 0)

        e = Event(begin=t, end=t + 1)
        l.append(e)

        self.assertEqual(len(l), 1)
        self.assertEqual(l[0], e)
예제 #12
0
    def test_eq(self):
        c0, c1 = Calendar(), Calendar()
        e = Event()

        c0.events.append(e)
        c1.events.append(e)

        self.assertEqual(c0, c1)

        t = Todo()

        c0.todos.append(t)
        c1.todos.append(t)
예제 #13
0
    def test_init(self):
        e = Event()

        self.assertEqual(e._duration, None)
        self.assertEqual(e._end_time, None)
        self.assertEqual(e._begin, None)
        self.assertEqual(e._begin_precision, 'second')
        self.assertNotEqual(e.uid, None)
        self.assertEqual(e.description, None)
        self.assertEqual(e.created, None)
        self.assertEqual(e.location, None)
        self.assertEqual(e.url, None)
        self.assertEqual(e._unused, Container(name='VEVENT'))
예제 #14
0
    def test_eq(self):
        # TODO : better equality check
        c0, c1 = Calendar(), Calendar()
        e = Event()

        c0.events.add(e)
        c1.events.add(e)

        self.assertEqual(c0, c1)

        t = Todo()

        c0.todos.add(t)
        c1.todos.add(t)
예제 #15
0
    def test_repeat_weekly(self):
        repeatable = Repeatable("WEEKLY", count=2, byday=["MO", "WE"])
        event = Event(name="Test repeatable #1",
                      begin=dt(2019, 1, 14, 13, 30),
                      duration=td(minutes=60),
                      rrule=repeatable)

        events = [
            event,
            Event(name="Test repeatable #1",
                  begin=dt(2019, 1, 16, 13, 30),
                  duration=td(minutes=60),
                  rrule=repeatable),
            Event(name="Test repeatable #1",
                  begin=dt(2019, 1, 21, 13, 30),
                  duration=td(minutes=60),
                  rrule=repeatable)
        ]

        i = 0
        for e in event.repeat():
            self.assertTrue(e.time_equals(events[i]))
            i += 1
예제 #16
0
    def test_escape_output(self):
        e = Event()

        e.name = "Hello, with \\ special; 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 \\\\ special\\; chars and \\n newlines",
             "DESCRIPTION:Every\\nwhere ! Yes\\, yes !",
             "LOCATION:Here\\; too", "UID:empty-uid", "END:VEVENT"))
        self.assertEqual(str(e), eq)
예제 #17
0
파일: event.py 프로젝트: tomschr/ics.py
    def test_init(self):
        e = Event()

        self.assertEqual(td(0), e.duration)
        self.assertEqual(None, e.end)
        self.assertEqual(None, e.begin)
        self.assertEqual('second', e.timespan.precision)
        self.assertNotEqual(None, e.uid)
        self.assertEqual(None, e.description)
        self.assertEqual(None, e.created)
        self.assertEqual(None, e.last_modified)
        self.assertEqual(None, e.location)
        self.assertEqual(None, e.geo)
        self.assertEqual(None, e.url)
        self.assertEqual(Container(name='VEVENT'), e.extra)
        self.assertEqual(None, e.status)
        self.assertEqual(None, e.organizer)
예제 #18
0
    def test_init(self):
        e = Event()

        self.assertEqual(e._duration, None)
        self.assertEqual(e._end_time, None)
        self.assertEqual(e._begin, None)
        self.assertEqual(e._begin_precision, 'second')
        self.assertNotEqual(e.uid, None)
        self.assertEqual(e.description, None)
        self.assertEqual(e.created, None)
        self.assertEqual(e.last_modified, None)
        self.assertEqual(e.location, None)
        self.assertEqual(e.geo, None)
        self.assertEqual(e.url, None)
        self.assertEqual(e.extra, Container(name='VEVENT'))
        self.assertEqual(e.status, None)
        self.assertEqual(e.organizer, None)
예제 #19
0
파일: event.py 프로젝트: tomschr/ics.py
    def test_escape_output(self):
        e = Event()

        e.name = "Hello, with \\ special; chars and \n newlines"
        e.location = "Here; too"
        e.description = "Every\nwhere ! Yes, yes !"
        e.dtstamp = dt(2013, 1, 1)
        e.uid = "empty-uid"

        eq = list(
            sorted([
                "BEGIN:VEVENT", "DTSTAMP:20130101T000000",
                "DESCRIPTION:Every\\nwhere ! Yes\\, yes !",
                "LOCATION:Here\\; too",
                "SUMMARY:Hello\\, with \\\\ special\\; chars and \\n newlines",
                "UID:empty-uid", "END:VEVENT"
            ]))
        self.assertEqual(list(sorted(str(e).splitlines())), eq)
예제 #20
0
    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"))
예제 #21
0
    def test_make_all_day3(self):
        begin = arrow.get("2018-12-23")
        end = arrow.get("2018-12-25")
        e = Event(begin=begin, end=end)

        self.assertEqual(e._begin, begin)
        self.assertEqual(e.begin, begin)

        self.assertEqual(e._end_time, end)
        self.assertEqual(e.end, end)

        e.make_all_day()

        self.assertEqual(e._begin, arrow.get("2018-12-23"))
        self.assertEqual(e.begin, arrow.get("2018-12-23"))
        self.assertEqual(e._begin_precision, "day")

        self.assertEqual(e._end_time, arrow.get("2018-12-26"))
        self.assertEqual(e.end, arrow.get("2018-12-26"))
예제 #22
0
    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))
예제 #23
0
파일: event.py 프로젝트: tomschr/ics.py
    def test_classification_output(self):
        e = Event(name="Name")
        self.assertNotIn("CLASS:PUBLIC", str(e).splitlines())

        e = Event(name="Name", classification='PUBLIC')
        self.assertIn("CLASS:PUBLIC", str(e).splitlines())

        e = Event(name="Name", classification='PRIVATE')
        self.assertIn("CLASS:PRIVATE", str(e).splitlines())

        e = Event(name="Name", classification='CONFIDENTIAL')
        self.assertIn("CLASS:CONFIDENTIAL", str(e).splitlines())

        e = Event(name="Name", classification='iana-token')
        self.assertIn("CLASS:iana-token", str(e).splitlines())

        e = Event(name="Name", classification='x-name')
        self.assertIn("CLASS:x-name", str(e).splitlines())
예제 #24
0
    def test_duration(self):
        e = Event()
        self.assertIsNone(e.duration)

        e1 = Event(begin="1993/05/24")
        e1.make_all_day()
        self.assertEqual(e1.duration, td(days=1))

        e2 = Event(begin="1993/05/24", end="1993/05/30")
        self.assertEqual(e2.duration, td(days=6))

        e3 = Event(begin="1993/05/24", duration=td(minutes=1))
        self.assertEqual(e3.duration, td(minutes=1))

        e4 = Event(begin="1993/05/24")
        self.assertEqual(e4.duration, td(0))

        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, td(hours=146))
예제 #25
0
파일: event.py 프로젝트: tomschr/ics.py
    def test_duration(self):
        e = Event()
        self.assertEqual(e.duration, td())

        e1 = Event(begin=dt(1993, 5, 24))
        e1.make_all_day()
        self.assertEqual(e1.duration, td(days=1))

        e2 = Event(begin=dt(1993, 5, 24), end=dt(1993, 5, 30))
        self.assertEqual(e2.duration, td(days=6))

        e3 = Event(begin=dt(1993, 5, 24), duration=td(minutes=1))
        self.assertEqual(e3.duration, td(minutes=1))

        e4 = Event(begin=dt(1993, 5, 24))
        self.assertEqual(e4.duration, td(0))

        e5 = Event(begin=dt(1993, 5, 24))
        e5.duration = {'days': 6, 'hours': 2}
        self.assertEqual(e5.end, dt(1993, 5, 30, 2, 0))
        self.assertEqual(e5.duration, td(hours=146))
예제 #26
0
    def test_repeat_yearly_by_date(self):
        repeatable = Repeatable("YEARLY",
                                until=arrow.Arrow.fromdatetime(
                                    dt(2022, 1, 30, 16, 00)),
                                bymonthday=[1, 15],
                                bymonth=[5])

        event = Event(name="Test repeatable #1",
                      begin=dt(2019, 5, 1, 15, 30),
                      duration=td(minutes=60),
                      rrule=repeatable)

        events = [
            event,
            Event(name="Test repeatable #1",
                  begin=dt(2019, 5, 15, 15, 30),
                  duration=td(minutes=60),
                  rrule=repeatable),
            Event(name="Test repeatable #1",
                  begin=dt(2020, 5, 1, 15, 30),
                  duration=td(minutes=60),
                  rrule=repeatable),
            Event(name="Test repeatable #1",
                  begin=dt(2020, 5, 15, 15, 30),
                  duration=td(minutes=60),
                  rrule=repeatable),
            Event(name="Test repeatable #1",
                  begin=dt(2021, 5, 1, 15, 30),
                  duration=td(minutes=60),
                  rrule=repeatable),
            Event(name="Test repeatable #1",
                  begin=dt(2021, 5, 15, 15, 30),
                  duration=td(minutes=60),
                  rrule=repeatable)
        ]

        i = 0
        for e in event.repeat():
            self.assertTrue(e.time_equals(events[i]))
            i += 1
예제 #27
0
    def test_repeat_monthly_by_date(self):
        repeatable = Repeatable("MONTHLY",
                                until=arrow.Arrow.fromdatetime(
                                    dt(2019, 9, 30, 16, 00)),
                                interval=3,
                                bymonthday=[1, 20])

        event = Event(name="Test repeatable #1",
                      begin=dt(2019, 1, 1, 15, 30),
                      duration=td(minutes=60),
                      rrule=repeatable)

        events = [
            event,
            Event(name="Test repeatable #1",
                  begin=dt(2019, 1, 20, 15, 30),
                  duration=td(minutes=60),
                  rrule=repeatable),
            Event(name="Test repeatable #1",
                  begin=dt(2019, 4, 1, 15, 30),
                  duration=td(minutes=60),
                  rrule=repeatable),
            Event(name="Test repeatable #1",
                  begin=dt(2019, 4, 20, 15, 30),
                  duration=td(minutes=60),
                  rrule=repeatable),
            Event(name="Test repeatable #1",
                  begin=dt(2019, 7, 1, 15, 30),
                  duration=td(minutes=60),
                  rrule=repeatable),
            Event(name="Test repeatable #1",
                  begin=dt(2019, 7, 20, 15, 30),
                  duration=td(minutes=60),
                  rrule=repeatable)
        ]

        i = 0
        for e in event.repeat():
            self.assertTrue(e.time_equals(events[i]))
            i += 1
예제 #28
0
 def test_repr(self):
     e = Event(name='plop', begin="1999/10/10")
     self.assertEqual(
         repr(e),
         "<Event 'plop' begin:1999-10-10T00:00:00+00:00 end:1999-10-10T00:00:00+00:00>"
     )
예제 #29
0
 def test_name_repr(self):
     e = Event(name='plop')
     self.assertEqual(repr(e), "<Event 'plop'>")
예제 #30
0
 def test_all_day_repr(self):
     e = Event(name='plop', begin="1999/10/10")
     e.make_all_day()
     self.assertEqual(repr(e), "<all-day Event 'plop' 1999-10-10>")