def expected_ics(self, *assignments):
        """ Returns hardcoded expected ics strings for given assignments """
        template = '''BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Open edX//calendar_sync//EN
METHOD:REQUEST
BEGIN:VEVENT
SUMMARY:{summary}
DTSTART;VALUE=DATE-TIME:{timedue}
DURATION:P0D
DTSTAMP;VALUE=DATE-TIME:20131003T082455Z
UID:{uid}
SEQUENCE:{sequence}
DESCRIPTION:{summary} is due for {course}.
ORGANIZER;CN=édX:mailto:[email protected]
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR
'''
        return (
            template.format(
                summary=assignment.title,
                course=self.course.display_name_with_default,
                timedue=assignment.date.strftime('%Y%m%dT%H%M%SZ'),
                uid=get_calendar_event_id(self.user, str(assignment.block_key), 'due', self.site_config.site.domain),
                sequence=self.user_calendar_sync_config.ics_sequence
            )
            for assignment in assignments
        )
Beispiel #2
0
    def expected_ics(self, *assignments):
        """ Returns hardcoded expected ics strings for given assignments """
        template = '''BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Open edX//calendar_sync//EN
METHOD:REQUEST
BEGIN:VEVENT
SUMMARY:{summary}
DTSTART;VALUE=DATE-TIME:{timedue}
DURATION:P0D
DTSTAMP;VALUE=DATE-TIME:20131003T082455Z
UID:{uid}
DESCRIPTION:<a href="{url}">Link</a>
ORGANIZER;CN=édX:mailto:[email protected]
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR
'''
        return (
            template.format(
                summary=assignment.title,
                timedue=assignment.date.strftime('%Y%m%dT%H%M%SZ'),
                url=assignment.url,
                uid=get_calendar_event_id(self.user, str(assignment.block_key), 'due', self.request.site.domain),
            )
            for assignment in assignments
        )
Beispiel #3
0
 def test_get_calendar_event_id(self):
     block_key = 'block-v1:Org+Number+Term+type@sequential+block@gibberish'
     date_type = 'due'
     hostname = 'example.com'
     event_id = get_calendar_event_id(self.user, block_key, date_type, hostname)
     expected = '{user_id}.{block_key}.{date_type}@{hostname}'.format(
         user_id=self.user.id, block_key=block_key, date_type=date_type, hostname=hostname
     )
     assert event_id == expected
Beispiel #4
0
 def test_get_calendar_event_id(self):
     block_key = 'block-v1:Org+Number+Term+type@sequential+block@gibberish'
     date_type = 'due'
     event_id = get_calendar_event_id(self.user, block_key, date_type)
     expected = '{username}.{block_key}.{date_type}'.format(
         username=self.user.username,
         block_key=block_key,
         date_type=date_type)
     self.assertEqual(event_id, expected)