Example #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'))
Example #2
0
    def test_availablity(self):
        """
        Test availability components
        """
        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')
        )
Example #3
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"
        cal.vevent.add('dtstamp').value = datetime.datetime(2017,
                                                            6,
                                                            26,
                                                            0,
                                                            tzinfo=tzutc())

        cal.vevent.add('attendee').value = 'mailto:[email protected]'
        cal.vevent.attendee.params['CN'] = ['Fröhlich']

        # 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'))
Example #4
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"
     )
Example #5
0
 def test_semicolon_separated(self):
     """
     Semi-colon separated multi-text serialization test
     """
     request_status = base.newFromBehavior('request-status')
     request_status.value = ['5.1', 'Service unavailable']
     self.assertEqual(request_status.serialize().strip(),
                      "REQUEST-STATUS:5.1;Service unavailable")
Example #6
0
 def test_vcard_creation(self):
     """
     Test creating a vCard
     """
     vcard = base.newFromBehavior('vcard', '3.0')
     self.assertEqual(
         str(vcard),
         "<VCARD| []>"
     )
Example #7
0
 def test_vcard_creation(self):
     """
     Test creating a vCard
     """
     vcard = base.newFromBehavior('vcard', '3.0')
     self.assertEqual(
         str(vcard),
         "<VCARD| []>"
     )
Example #8
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")
Example #9
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')
        )
Example #10
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')
        )
Example #11
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"
        )
Example #12
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'))
Example #13
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'))