From 6e141e18bf66f942fa41b7ad18960bae533e46b3 Mon Sep 17 00:00:00 2001 From: asadiqbal Date: Mon, 15 Jun 2015 19:24:16 +0500 Subject: [PATCH 1/2] SOL-639 --- milestones/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/milestones/api.py b/milestones/api.py index bff7266d..327802e0 100644 --- a/milestones/api.py +++ b/milestones/api.py @@ -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, From d6cf35f523dab28068101e5d3674590a3d5ff7e1 Mon Sep 17 00:00:00 2001 From: asadiqbal Date: Tue, 16 Jun 2015 15:46:50 +0500 Subject: [PATCH 2/2] SOL-961 added a test for special characters in milestone name --- milestones/tests/test_api.py | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/milestones/tests/test_api.py b/milestones/tests/test_api.py index 9e3a5fb0..28c72d1c 100644 --- a/milestones/tests/test_api.py +++ b/milestones/tests/test_api.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # pylint: disable=invalid-name # pylint: disable=too-many-public-methods """ @@ -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