Ejemplo n.º 1
0
 def test_list_to_eventlist(self):
     c = Calendar()
     l = [Event(), Event(), Event(name='plop')]
     c.events = l
     self.assertIsNot(c.events, l)
     self.assertIsInstance(c.events, EventList)
     self.assertSequenceEqual(c.events, l)
Ejemplo n.º 2
0
    def test_todos_setter(self):

        c = Calendar(cal1)
        t = Todo()
        c.todos = [t]

        self.assertEqual(c.todos, [t])
Ejemplo n.º 3
0
 def test_empty_list_to_eventlist(self):
     c = Calendar()
     l = []
     c.events = l
     self.assertIsNot(c.events, l)
     self.assertIsInstance(c.events, EventList)
     self.assertSequenceEqual(c.events, l)
Ejemplo n.º 4
0
    def test_events_setter(self):

        c = Calendar(cal1)
        e = Event()
        c.events = [e]

        self.assertEqual(c.events, [e])
Ejemplo n.º 5
0
    def test_clone(self):
        c0 = Calendar()
        e = Event()
        c0.events.add(e)
        c1 = c0.clone()

        self.assertEqual(c0.events, c1.events)
        self.assertEqual(c0, c1)
Ejemplo n.º 6
0
    def test_creator(self):

        c0 = Calendar()
        c1 = Calendar()
        c0.creator = u'42'
        with self.assertRaises(ValueError):
            c1.creator = 42

        self.assertEqual(c0.creator, u'42')
Ejemplo n.º 7
0
    def test_events_eventlist(self):

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

        self.assertEqual(c.events, [e])
Ejemplo n.º 8
0
    def test_clone(self):
        c0 = Calendar()
        e = Event()
        c0.events.append(e)
        c1 = c0.clone()

        self.assertTrue(len(c0.events) == len(c1.events))
        self.assertEqual(c0.events[0], c1.events[0])
        self.assertEqual(c0, c1)
Ejemplo n.º 9
0
    def test_urepr(self):
        # TODO : more cases
        c = Calendar()
        self.assertEqual(c.__urepr__(), '<Calendar with 0 event>')

        c.events.append(Event())
        self.assertEqual(c.__urepr__(), '<Calendar with 1 event>')

        c.events.append(Event())
        self.assertEqual(c.__urepr__(), '<Calendar with 2 events>')
Ejemplo n.º 10
0
    def test_creator(self):

        c0 = Calendar()
        c1 = Calendar()
        c0.creator = u'42'
        # TextProperties are cast to a string type
        c1.creator = 42

        self.assertEqual(c0.creator, u'42')
        self.assertEqual(c1.creator, u'42')
Ejemplo n.º 11
0
    def test_repr(self):
        # TODO : more cases
        c = Calendar()
        self.assertEqual(c.__repr__(), '<Calendar with 0 event and 0 todo>')

        c.events.add(Event())
        c.todos.add(Todo())
        self.assertEqual(c.__repr__(), '<Calendar with 1 event and 1 todo>')

        c.events.add(Event())
        c.todos.add(Todo())
        self.assertEqual(c.__repr__(), '<Calendar with 2 events and 2 todos>')
Ejemplo n.º 12
0
    def test_events_set_string(self):

        c = Calendar(cal1)
        e = "42"
        with self.assertRaises(ValueError):
            c.events = e
Ejemplo n.º 13
0
 def test_fixtures_time(self):
     with open(os.path.join(os.path.dirname(__file__),
                            "fixtures/time.ics")) as f:
         Calendar(f.read().replace("BEGIN:VCALENDAR",
                                   "BEGIN:VCALENDAR\nPRODID:Fixture"))
Ejemplo n.º 14
0
    def test_events_set_int(self):

        c = Calendar()

        with self.assertRaises(ValueError):
            c.events = 42
Ejemplo n.º 15
0
 def test_all_day_duration(self):
     c = Calendar(cal17)
     e = c.events[0]
     self.assertTrue(e.all_day)
     self.assertEqual(e.duration, timedelta(days=3))
Ejemplo n.º 16
0
 def test_fixtures_timezoned(self):
     with open(
             os.path.join(os.path.dirname(__file__),
                          "fixtures/timezoned.ics")) as f:
         Calendar(f.read())
Ejemplo n.º 17
0
 def test_issue_90(self):
     Calendar(cal32)
Ejemplo n.º 18
0
 def test_all_day_with_end(self):
     c = Calendar(cal17)
     e = c.events[0]
     self.assertTrue(e.all_day)
Ejemplo n.º 19
0
    def test_init_int(self):

        with self.assertRaises(TypeError):
            Calendar(42)
Ejemplo n.º 20
0
 def test_repr(self):
     c = Calendar()
     self.assertEqual(c.__urepr__(), repr(c))
Ejemplo n.º 21
0
 def test_fixtures_utf_8_emoji(self):
     with open(
             os.path.join(os.path.dirname(__file__),
                          "fixtures/utf-8-emoji.ics")) as f:
         Calendar(f.read())
Ejemplo n.º 22
0
    def test_multiple_calendars(self):

        with self.assertRaises(TypeError):
            Calendar() + Calendar()
Ejemplo n.º 23
0
    def test_scale(self):

        c = Calendar(cal10)

        self.assertEqual(c.scale, u'georgian')
Ejemplo n.º 24
0
    def test_existing_creator(self):
        c = Calendar(cal1)
        self.assertEqual(c.creator, u'-//Apple Inc.//Mac OS X 10.9//EN')

        c.creator = u"apple_is_a_fruit"
        self.assertEqual(c.creator, u"apple_is_a_fruit")
Ejemplo n.º 25
0
 def test_neq_creator(self):
     c0, c1 = Calendar(), Calendar(creator="test")
     self.assertNotEqual(c0, c1)
Ejemplo n.º 26
0
 def test_repr(self):
     c = Calendar()
     self.assertEqual(c.__urepr__(), repr(c))
Ejemplo n.º 27
0
 def test_status_input(self):
     c = Calendar(cal16)
     e = next(iter(c.events))
     self.assertEqual(e.status, "CONFIRMED")
Ejemplo n.º 28
0
 def test_fixtures_encoding(self):
     with open(
             os.path.join(os.path.dirname(__file__),
                          "fixtures/encoding.ics")) as f:
         Calendar(f.read())
Ejemplo n.º 29
0
 def test_category_input(self):
     c = Calendar(cal16)
     e = next(iter(c.events))
     self.assertIn("Simple Category", e.categories)
     self.assertIn("My \"Quoted\" Category", e.categories)
     self.assertIn("Category, with comma", e.categories)
Ejemplo n.º 30
0
 def test_url_input(self):
     c = Calendar(cal16)
     e = c.events[0]
     self.assertEqual(e.url,
                      "http://example.com/pub/calendars/jsmith/mytime.ics")
Ejemplo n.º 31
0
 def test_all_day_with_end(self):
     c = Calendar(cal20)
     e = next(iter(c.events))
     self.assertTrue(e.all_day)
Ejemplo n.º 32
0
 def test_not_all_day(self):
     c = Calendar(cal16)
     e = c.events[0]
     self.assertFalse(e.all_day)
Ejemplo n.º 33
0
 def test_not_duration_and_end(self):
     c = Calendar(calendar_with_duration_and_end)
     with self.assertRaises(ValueError):
         c.validate()
Ejemplo n.º 34
0
 def test_event_with_duration(self):
     c = Calendar(cal12)
     e = c.events[0]
     self.assertEqual(e._duration, timedelta(1, 3600))
     self.assertEqual(e.end - e.begin, timedelta(1, 3600))
Ejemplo n.º 35
0
 def test_no_prodid(self):
     c = Calendar(calendar_without_prodid)
     with self.assertRaises(ValueError):
         c.validate()
Ejemplo n.º 36
0
    def test_existing_creator(self):
        c = Calendar(cal1)
        self.assertEqual(c.creator, u'-//Apple Inc.//Mac OS X 10.9//EN')

        c.creator = u"apple_is_a_fruit"
        self.assertEqual(c.creator, u"apple_is_a_fruit")
Ejemplo n.º 37
0
 def test_default_transparent_input(self):
     c = Calendar(cal18)
     e = next(iter(c.events))
     self.assertEqual(e.transparent, False)
Ejemplo n.º 38
0
 def test_fixtures_recurrence(self):
     with open(
             os.path.join(os.path.dirname(__file__),
                          "fixtures/recurrence.ics")) as f:
         Calendar(f.read())
Ejemplo n.º 39
0
 def test_event_with_duration(self):
     c = Calendar(cal12)
     e = next(iter(c.events))
     self.assertEqual(e._duration, td(1, 3600))
     self.assertEqual(e.end - e.begin, td(1, 3600))
Ejemplo n.º 40
0
 def test_fixtures_multiple(self):
     with open(
             os.path.join(os.path.dirname(__file__),
                          "fixtures/multiple.ics")) as f:
         Calendar.parse_multiple(f.read())
Ejemplo n.º 41
0
 def test_not_duration_and_end(self):
     with self.assertRaises(ValueError):
         Calendar(cal13)
Ejemplo n.º 42
0
 def test_fixtures_groupscheduled(self):
     with open(
             os.path.join(os.path.dirname(__file__),
                          "fixtures/groupscheduled.ics")) as f:
         Calendar(f.read())
Ejemplo n.º 43
0
    def test_issue_92(self):
        c = Calendar(cal32)
        e = list(c.events)[0]

        assert e.begin == arrow.get('2016-10-04')
        assert e.end == arrow.get('2016-10-05')
Ejemplo n.º 44
0
 def test_eventlist_is_same(self):
     c = Calendar()
     l = EventList()
     c.events = l
     self.assertIs(c.events, l)
Ejemplo n.º 45
0
 def test_unescapte_texts(self):
     c = Calendar(cal15)
     e = c.events[1]
     self.assertEqual(e.name, "Some special ; chars")
     self.assertEqual(e.location, "In, every text field")
     self.assertEqual(e.description, "Yes, all of them;")
Ejemplo n.º 46
0
 def test_not_all_day(self):
     c = Calendar(cal16)
     e = next(iter(c.events))
     self.assertFalse(e.all_day)
Ejemplo n.º 47
0
 def test_fixtures_spaces(self):
     with open(
             os.path.join(os.path.dirname(__file__),
                          "fixtures/spaces.ics")) as f:
         Calendar(f.read())
Ejemplo n.º 48
0
 def test_bad_type(self):
     container = Container(name='VINVALID')
     with self.assertRaises(ValueError):
         Calendar._from_container(container)
Ejemplo n.º 49
0
 def test_all_day_duration(self):
     c = Calendar(cal20)
     e = next(iter(c.events))
     self.assertTrue(e.all_day)
     self.assertEqual(e.duration, td(days=2))