Esempio n. 1
0
    def test_set_slice_fail(self):

        l = EventList()
        for i in range(6):
            l.append(Event())
        with self.assertRaises(ValueError):
            l[2:4] = [Event(), "coucou, tu veux voir ma b*** ?"]
Esempio n. 2
0
    def test_on(self):

        l = EventList()

        c = Calendar(cal1)
        l.append(c.events[0])
        day = "2013-10-29"
        self.assertIn(c.events[0], l.on(day))
Esempio n. 3
0
    def test_now_short(self):

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

        e = Event("test", t.replace(seconds=-1), t.replace(seconds=+1))
        l.append(e)

        self.assertIn(e, l.now())
Esempio n. 4
0
    def test_now_large(self):

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

        e = Event("test", t.replace(years=-1), t.replace(years=+1))
        l.append(e)

        self.assertIn(e, l.now())
Esempio n. 5
0
    def test_events_eventlist(self):

        c = Calendar()
        l = EventList()
        e = Event()
        l.append(e)
        c.events = l

        self.assertEqual(c.events, [e])
Esempio n. 6
0
    def test_events_eventlist(self):

        c = Calendar()
        l = EventList()
        e = Event()
        l.append(e)
        c.events = l

        self.assertEqual(c.events, [e])
Esempio n. 7
0
    def test_at_is_now(self):

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

        e = Event("test", t.replace(seconds=-1), t.replace(seconds=+1))
        l.append(e)

        self.assertIn(e, l.at(instant))
Esempio n. 8
0
    def test_concurrent(self):

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

        e0 = Event("t0", t.replace(hours=-1), t.replace(hours=+1))
        e1 = Event("t1", t.replace(minutes=-59), t.replace(hours=+59))
        l.append(e0)

        self.assertEqual([e0], l.concurrent(e1))
Esempio n. 9
0
    def test_at_is_later(self):

        l = EventList()
        t = arrow.now()
        instant = arrow.now().replace(minutes=+1)

        e = Event("test", t.replace(seconds=-1), t.replace(seconds=+59))
        l.append(e)

        self.assertNotIn(e, l.at(instant))
Esempio n. 10
0
    def test_getitem_arrow(self):

        l = EventList()
        t = arrow.get("20130303T101010")

        e = Event("t", t.replace(hours=-1), t.replace(hours=+1))
        l.append(e)
        t = t.format('YYYY-MM-DD')

        self.assertEqual([e], l[t])
Esempio n. 11
0
    def test_inc(self):

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

        e0 = Event(begin=t.replace(hours=-1), end=t.replace(hours=+1))
        e1 = Event(begin=t.replace(minutes=-30), end=t.replace(minutes=+30))
        l.append(e0)
        l = l[e1.begin:e1.end:'inc']

        self.assertEqual([e0], l)
Esempio n. 12
0
    def test_both(self):

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

        e0 = Event(begin=t.replace(hours=-1), end=t.replace(hours=+1))
        e1 = Event(begin=t.replace(minutes=-30), end=t.replace(minutes=+30))
        l.append(e1)
        l = l[e0.begin:e0.end:]

        self.assertEqual([e1], l)
Esempio n. 13
0
    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)
Esempio n. 14
0
    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)
Esempio n. 15
0
    def test_today(self):

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

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

        self.assertEqual(l.today(), [e])
        l.append(Event(begin=t, end=t + 86400))
        self.assertEqual(l.today(strict=True), [e])
Esempio n. 16
0
    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))
Esempio n. 17
0
    def test_set_slice(self):

        fix = [Event(), Event(), Event(), Event(), Event(), Event()]
        fix2 = [Event(name="test"), Event(name="test2")]

        l = EventList(fix)
        l[2:4] = fix2
        fix[2:4] = fix2

        self.assertSequenceEqual(sorted(fix), sorted(l))
Esempio n. 18
0
    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']
Esempio n. 19
0
    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))
Esempio n. 20
0
    def test_remove_duplicate_diff(self):

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

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

        self.assertEqual(2, len(l))
Esempio n. 21
0
    def test_inc_empty(self):

        l = EventList()
        l = l[::'inc']

        self.assertEqual([], l)
Esempio n. 22
0
 def test_set_elem_fail(self):
     l = EventList([Event(), Event()])
     with self.assertRaises(ValueError):
         l[3] = "plop"
Esempio n. 23
0
 def test_eventlist_is_same(self):
     c = Calendar()
     l = EventList()
     c.events = l
     self.assertIs(c.events, l)