diff --git a/edx_when/__init__.py b/edx_when/__init__.py index 891e777..a855068 100644 --- a/edx_when/__init__.py +++ b/edx_when/__init__.py @@ -4,6 +4,6 @@ from __future__ import absolute_import, unicode_literals -__version__ = '0.3' +__version__ = '0.4' default_app_config = 'edx_when.apps.EdxWhenConfig' # pylint: disable=invalid-name diff --git a/edx_when/api.py b/edx_when/api.py index 1adc450..0a2ab00 100644 --- a/edx_when/api.py +++ b/edx_when/api.py @@ -74,7 +74,7 @@ def get_dates_for_course(course_id, user=None, use_cached=True): """ log.debug("Getting dates for %s as %s", course_id, user) - cache_key = 'course_dates.%s' + cache_key = 'course_dates.%s' % course_id if user: if isinstance(user, int): user_id = user diff --git a/test_utils/__init__.py b/test_utils/__init__.py index 6c4fea0..be8f2a4 100644 --- a/test_utils/__init__.py +++ b/test_utils/__init__.py @@ -19,14 +19,14 @@ def make_block_id(course_id='testX+tt101+2019', block_type='sequential+block'): return UsageKey.from_string(block_id) -def make_items(): +def make_items(course_id='testX+tt101+2019'): """ Return item list for set_dates_for_course. """ items = [ - (make_block_id(), {'due': datetime(2019, 3, 22)}), - (make_block_id(), {'due': datetime(2019, 3, 23), 'test': '1'}), - (make_block_id(), {'start': datetime(2019, 3, 21), 'test': '1'}), - (make_block_id(), {'start': None, 'test': '1'}), + (make_block_id(course_id), {'due': datetime(2019, 3, 22)}), + (make_block_id(course_id), {'due': datetime(2019, 3, 23), 'test': '1'}), + (make_block_id(course_id), {'start': datetime(2019, 3, 21), 'test': '1'}), + (make_block_id(course_id), {'start': None, 'test': '1'}), ] return items diff --git a/tests/test_api.py b/tests/test_api.py index 2e5629f..4abd888 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -42,6 +42,15 @@ def test_get_dates_for_course(self): # second time is cached retrieved = api.get_dates_for_course(items[0][0].course_key) assert len(retrieved) == 3 + + # third time with new course_id + new_items = make_items('testX+tt202+2019') + api.set_dates_for_course(new_items[0][0].course_key, new_items) + new_retrieved = api.get_dates_for_course(new_items[0][0].course_key) + assert len(new_retrieved) == 3 + first_id = list(new_retrieved.keys())[0][0] + last_id = list(retrieved.keys())[0][0] + assert first_id.course_key != last_id.course_key return items def test_clear_dates_for_course(self):