示例#1
0
    def test_availablity(self):
        test_cal = get_test_file("availablity.ics")

        vcal = base.newFromBehavior('VAVAILABILITY')
        vcal.add('uid').value = 'test'
        vcal.add('dtstamp').value = datetime.datetime(2006,
                                                      2,
                                                      15,
                                                      0,
                                                      tzinfo=utc)
        vcal.add('dtstart').value = datetime.datetime(2006,
                                                      2,
                                                      16,
                                                      0,
                                                      tzinfo=utc)
        vcal.add('dtend').value = datetime.datetime(2006, 2, 17, 0, tzinfo=utc)
        vcal.add('busytype').value = "BUSY"

        av = base.newFromBehavior('AVAILABLE')
        av.add('uid').value = 'test1'
        av.add('dtstamp').value = datetime.datetime(2006, 2, 15, 0, tzinfo=utc)
        av.add('dtstart').value = datetime.datetime(2006, 2, 16, 9, tzinfo=utc)
        av.add('dtend').value = datetime.datetime(2006, 2, 16, 12, tzinfo=utc)
        av.add('summary').value = "Available in the morning"

        vcal.add(av)

        self.assertEqual(vcal.serialize().replace('\r\n', '\n'),
                         test_cal.replace('\r\n', '\n'))
示例#2
0
 def test_semicolon_separated(self):
     """Semi-colon separated multi-text serialization test"""
     requestStatus = base.newFromBehavior('request-status')
     requestStatus.value = ['5.1', 'Service unavailable']
     self.assertEqual(
         requestStatus.serialize().strip(),
         "REQUEST-STATUS:5.1;Service unavailable"
     )
示例#3
0
    def test_availablity(self):
        test_cal = get_test_file("availablity.ics")

        vcal = base.newFromBehavior('VAVAILABILITY')
        vcal.add('uid').value = 'test'
        vcal.add('dtstamp').value = datetime.datetime(2006, 2, 15, 0, tzinfo=utc)
        vcal.add('dtstart').value = datetime.datetime(2006, 2, 16, 0, tzinfo=utc)
        vcal.add('dtend').value   = datetime.datetime(2006, 2, 17, 0, tzinfo=utc)
        vcal.add('busytype').value = "BUSY"

        av = base.newFromBehavior('AVAILABLE')
        av.add('uid').value = 'test1'
        av.add('dtstamp').value = datetime.datetime(2006, 2, 15, 0, tzinfo=utc)
        av.add('dtstart').value = datetime.datetime(2006, 2, 16, 9, tzinfo=utc)
        av.add('dtend').value   = datetime.datetime(2006, 2, 16, 12, tzinfo=utc)
        av.add('summary').value = "Available in the morning"

        vcal.add(av)

        self.assertEqual(
            vcal.serialize().replace('\r\n', '\n'),
            test_cal.replace('\r\n', '\n')
        )
示例#4
0
    def test_freeBusy(self):
        test_cal = get_test_file("freebusy.ics")

        vfb = base.newFromBehavior('VFREEBUSY')
        vfb.add('uid').value = 'test'
        vfb.add('dtstart').value = datetime.datetime(2006, 2, 16, 1, tzinfo=utc)
        vfb.add('dtend').value   = vfb.dtstart.value + twoHours
        vfb.add('freebusy').value = [(vfb.dtstart.value, twoHours / 2)]
        vfb.add('freebusy').value = [(vfb.dtstart.value, vfb.dtend.value)]

        self.assertEqual(
            vfb.serialize().replace('\r\n', '\n'),
            test_cal.replace('\r\n', '\n')
        )
示例#5
0
    def test_scratchbuild(self):
        "CreateCalendar 2.0 format from scratch"
        test_cal = get_test_file("simple_2_0_test.ics")
        cal = base.newFromBehavior('vcalendar', '2.0')
        cal.add('vevent')
        cal.vevent.add('dtstart').value = datetime.datetime(2006, 5, 9)
        cal.vevent.add('description').value = "Test event"
        cal.vevent.add('created').value = datetime.datetime(2006, 1, 1, 10, tzinfo=dateutil.tz.tzical("test_files/timezones.ics").get('US/Pacific'))
        cal.vevent.add('uid').value = "Not very random UID"

        # Note we're normalizing line endings, because no one got time for that.
        self.assertEqual(
            cal.serialize().replace('\r\n', '\n'),
            test_cal.replace('\r\n', '\n')
        )
示例#6
0
    def test_freeBusy(self):
        test_cal = get_test_file("freebusy.ics")

        vfb = base.newFromBehavior('VFREEBUSY')
        vfb.add('uid').value = 'test'
        vfb.add('dtstart').value = datetime.datetime(2006,
                                                     2,
                                                     16,
                                                     1,
                                                     tzinfo=utc)
        vfb.add('dtend').value = vfb.dtstart.value + twoHours
        vfb.add('freebusy').value = [(vfb.dtstart.value, twoHours / 2)]
        vfb.add('freebusy').value = [(vfb.dtstart.value, vfb.dtend.value)]

        self.assertEqual(vfb.serialize().replace('\r\n', '\n'),
                         test_cal.replace('\r\n', '\n'))
示例#7
0
    def test_multiline(self):
        """
        Multi-text serialization test
        """
        category = base.newFromBehavior('categories')
        category.value = ['Random category']
        self.assertEqual(
            category.serialize().strip(),
            "CATEGORIES:Random category"
        )

        category.value.append('Other category')
        self.assertEqual(
            category.serialize().strip(),
            "CATEGORIES:Random category,Other category"
        )
示例#8
0
    def test_scratchbuild(self):
        "CreateCalendar 2.0 format from scratch"
        test_cal = get_test_file("simple_2_0_test.ics")
        cal = base.newFromBehavior('vcalendar', '2.0')
        cal.add('vevent')
        cal.vevent.add('dtstart').value = datetime.datetime(2006, 5, 9)
        cal.vevent.add('description').value = "Test event"
        cal.vevent.add('created').value = datetime.datetime(
            2006,
            1,
            1,
            10,
            tzinfo=dateutil.tz.tzical("test_files/timezones.ics").get(
                'US/Pacific'))
        cal.vevent.add('uid').value = "Not very random UID"

        # Note we're normalizing line endings, because no one got time for that.
        self.assertEqual(cal.serialize().replace('\r\n', '\n'),
                         test_cal.replace('\r\n', '\n'))
示例#9
0
 def test_vcard_creation(self):
     vcard = base.newFromBehavior('vcard', '3.0')
     self.assertEqual(str(vcard), "<VCARD| []>")
示例#10
0
 def test_semicolon_separated(self):
     """Semi-colon separated multi-text serialization test"""
     requestStatus = base.newFromBehavior('request-status')
     requestStatus.value = ['5.1', 'Service unavailable']
     self.assertEqual(requestStatus.serialize().strip(),
                      "REQUEST-STATUS:5.1;Service unavailable")
示例#11
0
 def test_vcard_creation(self):
     vcard = base.newFromBehavior('vcard', '3.0')
     self.assertEqual(
         str(vcard),
         "<VCARD| []>"
     )