Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions openedx/features/calendar_sync/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
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
Empty file.
25 changes: 25 additions & 0 deletions openedx/features/calendar_sync/tests/test_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
""" 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)