示例#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)
示例#2
0
    def test_todos_setter(self):

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

        self.assertEqual(c.todos, [t])
示例#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)
示例#4
0
    def test_events_setter(self):

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

        self.assertEqual(c.events, [e])
示例#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)
示例#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')
示例#7
0
    def test_events_eventlist(self):

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

        self.assertEqual(c.events, [e])
示例#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)
示例#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>')
示例#10
0
文件: calendar.py 项目: jammon/ics.py
    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')
示例#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>')
示例#12
0
    def test_events_set_string(self):

        c = Calendar(cal1)
        e = "42"
        with self.assertRaises(ValueError):
            c.events = e
示例#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"))
示例#14
0
    def test_events_set_int(self):

        c = Calendar()

        with self.assertRaises(ValueError):
            c.events = 42
示例#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))
示例#16
0
 def test_fixtures_timezoned(self):
     with open(
             os.path.join(os.path.dirname(__file__),
                          "fixtures/timezoned.ics")) as f:
         Calendar(f.read())
示例#17
0
 def test_issue_90(self):
     Calendar(cal32)
示例#18
0
 def test_all_day_with_end(self):
     c = Calendar(cal17)
     e = c.events[0]
     self.assertTrue(e.all_day)
示例#19
0
    def test_init_int(self):

        with self.assertRaises(TypeError):
            Calendar(42)
示例#20
0
 def test_repr(self):
     c = Calendar()
     self.assertEqual(c.__urepr__(), repr(c))
示例#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())
示例#22
0
    def test_multiple_calendars(self):

        with self.assertRaises(TypeError):
            Calendar() + Calendar()
示例#23
0
    def test_scale(self):

        c = Calendar(cal10)

        self.assertEqual(c.scale, u'georgian')
示例#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")
示例#25
0
 def test_neq_creator(self):
     c0, c1 = Calendar(), Calendar(creator="test")
     self.assertNotEqual(c0, c1)
示例#26
0
 def test_repr(self):
     c = Calendar()
     self.assertEqual(c.__urepr__(), repr(c))
示例#27
0
 def test_status_input(self):
     c = Calendar(cal16)
     e = next(iter(c.events))
     self.assertEqual(e.status, "CONFIRMED")
示例#28
0
 def test_fixtures_encoding(self):
     with open(
             os.path.join(os.path.dirname(__file__),
                          "fixtures/encoding.ics")) as f:
         Calendar(f.read())
示例#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)
示例#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")
示例#31
0
 def test_all_day_with_end(self):
     c = Calendar(cal20)
     e = next(iter(c.events))
     self.assertTrue(e.all_day)
示例#32
0
 def test_not_all_day(self):
     c = Calendar(cal16)
     e = c.events[0]
     self.assertFalse(e.all_day)
示例#33
0
文件: event.py 项目: jammon/ics.py
 def test_not_duration_and_end(self):
     c = Calendar(calendar_with_duration_and_end)
     with self.assertRaises(ValueError):
         c.validate()
示例#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))
示例#35
0
文件: calendar.py 项目: jammon/ics.py
 def test_no_prodid(self):
     c = Calendar(calendar_without_prodid)
     with self.assertRaises(ValueError):
         c.validate()
示例#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")
示例#37
0
 def test_default_transparent_input(self):
     c = Calendar(cal18)
     e = next(iter(c.events))
     self.assertEqual(e.transparent, False)
示例#38
0
 def test_fixtures_recurrence(self):
     with open(
             os.path.join(os.path.dirname(__file__),
                          "fixtures/recurrence.ics")) as f:
         Calendar(f.read())
示例#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))
示例#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())
示例#41
0
 def test_not_duration_and_end(self):
     with self.assertRaises(ValueError):
         Calendar(cal13)
示例#42
0
 def test_fixtures_groupscheduled(self):
     with open(
             os.path.join(os.path.dirname(__file__),
                          "fixtures/groupscheduled.ics")) as f:
         Calendar(f.read())
示例#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')
示例#44
0
 def test_eventlist_is_same(self):
     c = Calendar()
     l = EventList()
     c.events = l
     self.assertIs(c.events, l)
示例#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;")
示例#46
0
 def test_not_all_day(self):
     c = Calendar(cal16)
     e = next(iter(c.events))
     self.assertFalse(e.all_day)
示例#47
0
 def test_fixtures_spaces(self):
     with open(
             os.path.join(os.path.dirname(__file__),
                          "fixtures/spaces.ics")) as f:
         Calendar(f.read())
示例#48
0
文件: component.py 项目: I-GV/ics.py
 def test_bad_type(self):
     container = Container(name='VINVALID')
     with self.assertRaises(ValueError):
         Calendar._from_container(container)
示例#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))