Skip to content

Commit

Permalink
Merge pull request #10 from edx/asadiqbal08/SOl-639
Browse files Browse the repository at this point in the history
(WIP) SOL-639
  • Loading branch information
mattdrayer committed Jun 17, 2015
2 parents 547f225 + d6cf35f commit 5299fdf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion milestones/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def get_course_milestones_fulfillment_paths(course_key, user):
# Build the set of fulfillment paths for the outstanding milestones
fulfillment_paths = {}
for milestone in required_milestones:
dict_key = '{}.{}'.format(milestone['namespace'], milestone['name'])
dict_key = '{}.{}'.format(milestone['namespace'].encode('utf-8'), milestone['name'].encode('utf-8'))
fulfillment_paths[dict_key] = {}
milestone_courses = data.fetch_milestone_courses(
milestone,
Expand Down
38 changes: 38 additions & 0 deletions milestones/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# pylint: disable=invalid-name
# pylint: disable=too-many-public-methods
"""
Expand Down Expand Up @@ -693,6 +694,43 @@ def test_remove_content_references(self):
milestones = api.get_course_content_milestones(self.test_course_key, self.test_content_key)
self.assertEqual(len(milestones), 0)

def test_milestones_fulfillment_paths_contains_special_characters(self):
"""
Unit Test: test_get_course_milestones_fulfillment_paths works correctly when milestone have some special
characters.
"""
namespace = unicode(self.test_course_key)
name = '�ťÉśt_Àübùr�'
local_milestone_1 = api.add_milestone({
'display_name': 'Local Milestone 1',
'name': name,
'namespace': namespace,
'description': 'Local Milestone 1 Description'
})

# Specify the milestone requirements
api.add_course_milestone(
self.test_course_key,
self.relationship_types['REQUIRES'],
local_milestone_1
)

# Specify the milestone fulfillments (via course and content)
api.add_course_milestone(
self.test_prerequisite_course_key,
self.relationship_types['FULFILLS'],
local_milestone_1
)
with self.assertNumQueries(4):
paths = api.get_course_milestones_fulfillment_paths(
self.test_course_key,
self.serialized_test_user
)

# Set up the key values we'll use to access/assert the response
milestone_key_1 = '{}.{}'.format(local_milestone_1['namespace'], local_milestone_1['name'])
self.assertEqual(len(paths[milestone_key_1]['courses']), 1)

def test_get_course_milestones_fulfillment_paths(self): # pylint: disable=too-many-statements
"""
Unit Test: test_get_course_milestones_fulfillment_paths
Expand Down

0 comments on commit 5299fdf

Please sign in to comment.