Skip to content
Snippets Groups Projects
Unverified Commit e738d046 authored by Dillon Dumesnil's avatar Dillon Dumesnil Committed by GitHub
Browse files

Merge pull request #23141 from edx/ddumesnil/create-calendar-event-id-AA-33

AA-33: Function to uniquely create calendar event id for user and assignment
parents 3f85ba3f 57dbb2d4
No related branches found
No related tags found
No related merge requests found
"""
Calendar syncing Course dates with a User.
"""
def get_calendar_event_id(user, block_key, date_type):
"""
Creates a unique event id based on a user and a course block key
Parameters:
user (User): The user requesting a calendar event
block_key (str): The block key containing the date for the calendar event
date_type (str): The type of the date (e.g. 'due', 'start', 'end', etc.)
Returns:
event id (str)
"""
return user.username + '.' + block_key + '.' + date_type
""" Tests the contents of the __init__.py file """
from django.test import TestCase
from openedx.features.calendar_sync import get_calendar_event_id
from student.tests.factories import UserFactory
TEST_PASSWORD = 'test'
class TestCalendarSyncInit(TestCase):
""" Tests for the contents of __init__.py """
def setUp(self):
super(TestCalendarSyncInit, self).setUp()
self.user = UserFactory(password=TEST_PASSWORD)
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment