Commit 3343f983 by chrisndodge

Merge pull request #105 from edx/cdodge/unicode-fullname

Add some more robustness in case a user's fullname has unicode charac…
parents 6cde76c7 d0d449d2
......@@ -341,10 +341,11 @@ class SoftwareSecureBackendProvider(ProctoringBackendProvider):
string = ""
for key in keys:
value = body_json[key]
if str(value) == 'True':
value = 'true'
if str(value) == 'False':
value = 'false'
if isinstance(value, bool):
if value:
value = 'true'
else:
value = 'false'
if isinstance(value, (list, tuple)):
for idx, arr in enumerate(value):
if isinstance(arr, dict):
......@@ -356,7 +357,7 @@ class SoftwareSecureBackendProvider(ProctoringBackendProvider):
else:
if value != "" and not value:
value = "null"
string += str(prefix) + str(key) + ":" + str(value).encode('utf-8') + '\n'
string += str(prefix) + str(key) + ":" + unicode(value).encode('utf-8') + '\n'
return string
......
# coding=utf-8
"""
Tests for the software_secure module
"""
......@@ -140,13 +141,26 @@ class SoftwareSecureTests(TestCase):
Tests to make sure we can parse a fullname which does not have any spaces in it
"""
def mock_profile_service(user_id): # pylint: disable=unused-argument
"""
Mocked out Profile callback endpoint
"""
return {'name': 'Bono'}
set_runtime_service('credit', MockCreditService())
exam_id = create_exam(
course_id='foo/bar/baz',
content_id='content',
exam_name='Sample Exam',
time_limit_mins=10,
is_proctored=True
)
with HTTMock(mock_response_content):
attempt_id = create_exam_attempt(exam_id, self.user.id, taking_as_proctored=True)
self.assertIsNotNone(attempt_id)
def test_unicode_attempt(self):
"""
Tests to make sure we can handle an attempt when a user's fullname has unicode characters in it
"""
set_runtime_service('profile', mock_profile_service)
set_runtime_service('credit', MockCreditService(profile_fullname=u'अआईउऊऋऌ अआईउऊऋऌ'))
exam_id = create_exam(
course_id='foo/bar/baz',
......
......@@ -17,13 +17,13 @@ class MockCreditService(object):
Simple mock of the Credit Service
"""
def __init__(self, enrollment_mode='verified'):
def __init__(self, enrollment_mode='verified', profile_fullname='Wolfgang von Strucker'):
"""
Initializer
"""
self.status = {
'enrollment_mode': enrollment_mode,
'profile_fullname': 'Wolfgang von Strucker',
'profile_fullname': profile_fullname,
'credit_requirement_status': []
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment