예제 #1
0
 def test_vtodo(self):
     vtodo = get_test_file("vtodo.ics")
     obj = base.readOne(vtodo)
     obj.vtodo.add('completed')
     obj.vtodo.completed.value = datetime.datetime(2015,5,5,13,30)
     self.assertEqual(obj.vtodo.completed.serialize()[0:23], 'COMPLETED:20150505T1330')
     obj = base.readOne(obj.serialize())
     self.assertEqual(obj.vtodo.completed.value, datetime.datetime(2015,5,5,13,30))
예제 #2
0
 def test_wrapping(self):
     """
     Should support an input file with a long text field covering multiple lines
     """
     test_journal = get_test_file("journal.ics")
     vobj = base.readOne(test_journal)
     vjournal = base.readOne(vobj.serialize())
     self.assertTrue('Joe, Lisa, and Bob' in vjournal.description.value)
     self.assertTrue('Tuesday.\n2.' in vjournal.description.value)
예제 #3
0
 def test_wrapping(self):
     """
     Should support an input file with a long text field covering multiple lines
     """
     test_journal = get_test_file("journal.ics")
     vobj = base.readOne(test_journal)
     vjournal = base.readOne(vobj.serialize())
     self.assertTrue('Joe, Lisa, and Bob' in vjournal.description.value)
     self.assertTrue('Tuesday.\n2.' in vjournal.description.value)
예제 #4
0
 def test_vtodo(self):
     vtodo = get_test_file("vtodo.ics")
     obj = base.readOne(vtodo)
     obj.vtodo.add('completed')
     obj.vtodo.completed.value = datetime.datetime(2015, 5, 5, 13, 30)
     self.assertEqual(obj.vtodo.completed.serialize()[0:23],
                      'COMPLETED:20150505T1330')
     obj = base.readOne(obj.serialize())
     self.assertEqual(obj.vtodo.completed.value,
                      datetime.datetime(2015, 5, 5, 13, 30))
예제 #5
0
    def test_unicode(self):
        test_cal = get_test_file("utf8_test.ics")
        vevent = base.readOne(test_cal).vevent
        vevent2 = base.readOne(vevent.serialize())
        self.assertEqual(str(vevent), str(vevent2))

        self.assertEqual(vevent.summary.value, 'The title こんにちはキティ')

        if sys.version_info[0] < 3:
            test_cal = test_cal.decode('utf-8')
            vevent = base.readOne(test_cal).vevent
            vevent2 = base.readOne(vevent.serialize())
            self.assertEqual(str(vevent), str(vevent2))
            self.assertEqual(vevent.summary.value, 'The title こんにちはキティ')
예제 #6
0
    def test_bad_line(self):
        cal = get_test_file("badline.ics")
        self.assertRaises(ParseError, base.readOne, cal)

        newcal = base.readOne(cal, ignoreUnreadable=True)
        self.assertEqual(str(newcal.vevent.x_bad_underscore),
                         '<X-BAD-UNDERSCORE{}TRUE>')
예제 #7
0
    def test_importing(self):
        cal = get_test_file("standard_test.ics")
        c = base.readOne(cal, validate=True)
        self.assertEqual(
            str(c.vevent.valarm.trigger),
            "<TRIGGER{}-1 day, 0:00:00>"
        )

        self.assertEqual(
            str(c.vevent.dtstart.value),
            "2002-10-28 14:00:00-08:00"
        )
        self.assertTrue(
            isinstance(c.vevent.dtstart.value, datetime.datetime)
        )
        self.assertEqual(
            str(c.vevent.dtend.value),
            "2002-10-28 15:00:00-08:00"
        )
        self.assertTrue(
            isinstance(c.vevent.dtend.value, datetime.datetime)
        )
        self.assertEqual(
            c.vevent.dtstamp.value,
            datetime.datetime(2002, 10, 28, 1, 17, 6, tzinfo=tzutc())
        )

        vevent = c.vevent.transformFromNative()
        self.assertEqual(
            str(vevent.rrule),
            "<RRULE{}FREQ=Weekly;COUNT=10>"
        )
예제 #8
0
 def test_readOne(self):
     cal = get_test_file("silly_test.ics")
     silly = base.readOne(cal, findBegin=False)
     self.assertEqual(
         str(silly),
         "<SILLYPROFILE| [<MORESTUFF{}this line is not folded, but in practice probably ought to be, as it is exceptionally long, and moreover demonstratively stupid>, <SILLYNAME{}name>, <STUFF{}foldedline>]>"
     )
     self.assertEqual(str(silly.stuff), "<STUFF{}foldedline>")
예제 #9
0
    def test_bad_line(self):
        cal = get_test_file("badline.ics")
        self.assertRaises(ParseError, base.readOne, cal)

        newcal = base.readOne(cal, ignoreUnreadable=True)
        self.assertEqual(
            str(newcal.vevent.x_bad_underscore),
            '<X-BAD-UNDERSCORE{}TRUE>'
        )
예제 #10
0
 def test_readOne(self):
     cal = get_test_file("silly_test.ics")
     silly = base.readOne(cal, findBegin=False)
     self.assertEqual(
         str(silly),
         "<SILLYPROFILE| [<MORESTUFF{}this line is not folded, but in practice probably ought to be, as it is exceptionally long, and moreover demonstratively stupid>, <SILLYNAME{}name>, <STUFF{}foldedline>]>"
     )
     self.assertEqual(
         str(silly.stuff),
         "<STUFF{}foldedline>"
     )
예제 #11
0
    def test_unicode(self):
        test_cal = get_test_file("utf8_test.ics")
        vevent = base.readOne(test_cal).vevent
        vevent2 = base.readOne(vevent.serialize())
        self.assertEqual(str(vevent), str(vevent2))

        self.assertEqual(
            vevent.summary.value,
            'The title こんにちはキティ'
        )

        if sys.version_info[0] < 3:
            test_cal = test_cal.decode('utf-8')
            vevent = base.readOne(test_cal).vevent
            vevent2 = base.readOne(vevent.serialize())
            self.assertEqual(str(vevent), str(vevent2))
            self.assertEqual(
                vevent.summary.value,
                'The title こんにちはキティ'
            )
예제 #12
0
 def test_recurrence(self):
     # Ensure date valued UNTILs in rrules are in a reasonable timezone,
     # and include that day (12/28 in this test)
     test_file = get_test_file("recurrence.ics")
     cal = base.readOne(test_file, findBegin=False)
     dates = list(cal.vevent.getrruleset())
     self.assertEqual(dates[0],
                      datetime.datetime(2006, 1, 26, 23, 0, tzinfo=tzutc()))
     self.assertEqual(dates[1],
                      datetime.datetime(2006, 2, 23, 23, 0, tzinfo=tzutc()))
     self.assertEqual(
         dates[-1], datetime.datetime(2006, 12, 28, 23, 0, tzinfo=tzutc()))
예제 #13
0
 def test_vcard_3_parsing(self):
     """
     VCARD 3.0 parse test
     """
     test_file = get_test_file("simple_3_0_test.ics")
     card = base.readOne(test_file, findBegin=False)
     # value not rendering correctly?
     #self.assertEqual(
     #    card.adr.value,
     #    "<Address: Haight Street 512;\nEscape, Test\nNovosibirsk,  80214\nGnuland>"
     #)
     self.assertEqual(
         card.org.value,
         "University of Novosibirsk, Department of Octopus Parthenogenesis")
예제 #14
0
 def test_vcard_3_parsing(self):
     """
     VCARD 3.0 parse test
     """
     test_file = get_test_file("simple_3_0_test.ics")
     card = base.readOne(test_file, findBegin=False)
     # value not rendering correctly?
     #self.assertEqual(
     #    card.adr.value,
     #    "<Address: Haight Street 512;\nEscape, Test\nNovosibirsk,  80214\nGnuland>"
     #)
     self.assertEqual(
         card.org.value,
         "University of Novosibirsk, Department of Octopus Parthenogenesis"
     )
예제 #15
0
    def test_importing(self):
        cal = get_test_file("standard_test.ics")
        c = base.readOne(cal, validate=True)
        self.assertEqual(str(c.vevent.valarm.trigger),
                         "<TRIGGER{}-1 day, 0:00:00>")

        self.assertEqual(str(c.vevent.dtstart.value),
                         "2002-10-28 14:00:00-08:00")
        self.assertTrue(isinstance(c.vevent.dtstart.value, datetime.datetime))
        self.assertEqual(str(c.vevent.dtend.value),
                         "2002-10-28 15:00:00-08:00")
        self.assertTrue(isinstance(c.vevent.dtend.value, datetime.datetime))
        self.assertEqual(
            c.vevent.dtstamp.value,
            datetime.datetime(2002, 10, 28, 1, 17, 6, tzinfo=tzutc()))

        vevent = c.vevent.transformFromNative()
        self.assertEqual(str(vevent.rrule), "<RRULE{}FREQ=Weekly;COUNT=10>")
예제 #16
0
 def test_recurrence(self):
     # Ensure date valued UNTILs in rrules are in a reasonable timezone,
     # and include that day (12/28 in this test)
     test_file = get_test_file("recurrence.ics")
     cal = base.readOne(test_file, findBegin=False)
     dates = list(cal.vevent.getrruleset())
     self.assertEqual(
         dates[0],
         datetime.datetime(2006, 1, 26, 23, 0, tzinfo=tzutc())
     )
     self.assertEqual(
         dates[1],
         datetime.datetime(2006, 2, 23, 23, 0, tzinfo=tzutc())
     )
     self.assertEqual(
         dates[-1],
         datetime.datetime(2006, 12, 28, 23, 0, tzinfo=tzutc())
     )
예제 #17
0
 def setUpClass(cls):
     cls.test_file = get_test_file("vcard_with_groups.ics")
     cls.card = base.readOne(cls.test_file)
예제 #18
0
 def setUpClass(cls):
     cls.test_file = get_test_file("vcard_with_groups.ics")
     cls.card = base.readOne(cls.test_file)